-
Notifications
You must be signed in to change notification settings - Fork 181
Working with files
Get the Metadata for a file or folder.
Example
$file = $dropbox->getMetadata("/hello-world.txt");
With options:
$file = $dropbox->getMetadata("/hello-world.txt", ["include_media_info" => true, "include_deleted" => true]);
Fetch file details:
//Id
$file->getId();
//Name
$file->getName();
//Size
$file->getSize();
The getMetadata()
method will return an instance of the FileMetadata
model.
For available options see: https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
Get the contents of a Folder.
Example
$listFolderContents = $dropbox->listFolder("/");
//Fetch Items
$items = $listFolderContents->getItems();
//Fetch Cusrsor for listFolderContinue()
$cursor = $listFolderContents->getCursor();
//If more items are available
$hasMoreItems = $listFolderContents->hasMoreItems();
The listFolder()
method will return an instance of the MetadataCollection
model.
$listFolderContents = $dropbox->listFolder("/");
//Fetch Items (Returns an instance of ModelCollection)
$items = $listFolderContents->getItems();
//All Items
$items->all();
//First Item
$items->first();
//Last Item
$items->last();
Further calling the getItems()
method of the MetadataCollection
model, will return an instance of the ModelCollection
model, which extends the awesome Collection class. See it's Available methods.
For available options see: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
Paginate through all files and retrieve updates to the folder, using the cursor retrieved from listFolder or listFolderContinue.
Example
$listFolderContents = $dropbox->listFolder("/");
//Process listFolder Items
...
//If more items are available
if ($listFolderContents->hasMoreItems()) {
//Fetch Cusrsor for listFolderContinue()
$cursor = $listFolderContents->getCursor();
//Paginate through the remaining items
$listFolderContinue = $dropbox->listFolderContinue($cursor);
$remainingItems = $listFolderContinue->getItems();
}
The listFolderContinue()
method will return an instance of the MetadataCollection
model, same as the listFolder
method.