Box API Sitewide

Component ID

2510164

Component name

Box API Sitewide

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

This is an API module to make it easy to integrate the Box.com service into your site. Other modules allow individual Drupal users to authorize their own Box.com account. This one supports the use case of a single, administrative Box.com account, which is used by your module in all its operations.

It was built for the use case of synchronizing files from a specific Box.com account to Drupal nodes.

Usage

Your module should have a dependency on this one.

* visit /admin/config/media/box_api_sitewide to configure your api credentials.

That's it! From now on you can get and use files from box like this:

  $file = Drupal::service('box_api_sitewide.file')->load('box-file-id-number');
  
  $file->getContents(); // Returns the file contents

You can get and use directories from Box like this:

  $directory = Drupal::service('box_api_sitewide.directory')->load('box-directory-id-number');
  
  $directory->getListing(); // Returns the contents of the directory.
  $directory->getRecursiveListing(); // Returns the files contained in the directory, recursively.

(the root directory of your box account is always ID 0)

Both kinds of box objects support the following other methods as well:

  $object->getTitle(); // Returns the file/directory name.
  $object->getParent(); // Returns the parent directory, if applicable
  $object->getParents(); // Returns an ordered array of members in the full path to the object