-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,211 +1,67 @@ | ||
# Dropbox upload | ||
Upload to dropbox | ||
# Google Drive Manager | ||
Google Drive Manager | ||
|
||
### Install | ||
``` | ||
composer require tbetool/dropbox-php | ||
composer require tbetool/google-drive-manager | ||
``` | ||
|
||
### Initialize | ||
``` | ||
$dropbox = new Dropbox($client_key, $client_secret, $access_token); | ||
$drive = new GoogleDriveManager('client_id', 'client_secret', 'access_token'); | ||
``` | ||
|
||
### set access token | ||
``` | ||
$dropbox->setAccessToken('access_token'); | ||
$drive->setAccessToken('access_token'); | ||
``` | ||
|
||
### Uploading | ||
### List items from folder | ||
``` | ||
$response = $dropbox->upload('/file/path', 'title'); | ||
$response = $drive->listFolder(); | ||
``` | ||
|
||
##### Response | ||
response will contain | ||
``` | ||
[ | ||
'id' => 'upload_id', | ||
'file_name' => 'uploaded file name' | ||
] | ||
``` | ||
|
||
### List folder items | ||
``` | ||
$dropbox->listFolder('path_of_folder'); | ||
``` | ||
default: **"/"** | ||
|
||
if no path is provided, it will list all items in root folder | ||
|
||
Response: | ||
``` | ||
[ | ||
'data' => [ | ||
(int) 0 => [ | ||
'.tag' => 'folder', | ||
'name' => 'my_apps', | ||
'path_lower' => '/my_apps', | ||
'path_display' => '/my_apps', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAAAw' | ||
], | ||
(int) 0 => [ | ||
'id' => '1BEfQmdMja45M3ewc548OhiQLh9or9P6KGpqYECipV6c', | ||
'name' => 'Resume of Anuj Sharma', | ||
'mime_type' => 'application/vnd.google-apps.document', | ||
'kind' => 'drive#file' | ||
], | ||
'cursor' => 'AAF8pZtHZJlfwPYrLcKMzbxCNpGaExOHSK-LN8I--pmujanZ1XwEw4CHAzw288liKjDbBCkAy1b5SDZMyKGnRqkpk7heOy3p1MoRt640O6xLleBXRNEn41kTQ4GaWpVLHPuWWiBXTFiOFuC_ig67zb9K2KSwnAW-iLRuaQDDcHZ7Fw', | ||
'has_more' => false | ||
] | ||
``` | ||
### list remaining items from folder | ||
if `has_more` is **true** in above request, pass the **cursor** value as second parameter to the same function | ||
``` | ||
$dropbox->listFolder('path_of_folder', $cursor); | ||
|
||
### Search for item | ||
``` | ||
|
||
### Get revisions of file | ||
``` | ||
$dropbox->getRevisions('file_path', $limit); | ||
$drive->search('query'); | ||
``` | ||
if **limit** is not provided, default is **3** | ||
|
||
Response: | ||
``` | ||
[ | ||
(int) 0 => [ | ||
'name' => 'OBdoTHEm.mp4', | ||
'path_lower' => '/obdothem.mp4', | ||
'path_display' => '/OBdoTHEm.mp4', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAAKg', | ||
'client_modified' => '2018-06-11T10:50:17Z', | ||
'server_modified' => '2018-06-11T10:50:17Z', | ||
'rev' => '1c1f916734', | ||
'size' => (int) 72821, | ||
'content_hash' => '25d03e535dc1e4ec86fb35b8fc56d4075a583adf007339217a906a4dabbed721' | ||
] | ||
] | ||
``` | ||
|
||
### search | ||
search for file/folder in folder | ||
``` | ||
$dropbox->search('zip', $path, $start, $max_results); | ||
``` | ||
if **path** is not provided, default search will be in root directory | ||
|
||
if **start** is not provided, default is **0** | ||
|
||
if **max_results** is not provided, default is **5** | ||
|
||
Response: | ||
``` | ||
[ | ||
'data' => [ | ||
(int) 0 => [ | ||
'.tag' => 'file', | ||
'name' => 'OBdoTHEm.mp4', | ||
'path_lower' => '/obdothem.mp4', | ||
'path_display' => '/OBdoTHEm.mp4', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAAKg', | ||
'client_modified' => '2018-06-11T10:50:17Z', | ||
'server_modified' => '2018-06-11T10:50:17Z', | ||
'rev' => '1c1f916734', | ||
'size' => (int) 72821, | ||
'content_hash' => '25d03e535dc1e4ec86fb35b8fc56d4075a583adf007339217a906a4dabbed721' | ||
] | ||
'id' => '1YoSEbFDSOejkZmtPmfOyBIoWODhllPjJ', | ||
'name' => 'Selling Digital Items Modules to be updated ', | ||
'kind' => null, | ||
'created_time' => null, | ||
'file_extension' => null, | ||
'mime_type' => null, | ||
'modified_time' => null, | ||
'original_filename' => null, | ||
'size' => null | ||
], | ||
'cursor' => (int) 1, | ||
'has_more' => false | ||
] | ||
``` | ||
|
||
### create folder | ||
create folder at specified path | ||
``` | ||
$dropbox->createFolder('/Folder Name'); | ||
``` | ||
|
||
Response: | ||
``` | ||
[ | ||
'name' => 'Folder Name', | ||
'path_lower' => '/folder name', | ||
'path_display' => '/Folder Name', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAAUg' | ||
] | ||
``` | ||
|
||
### delete | ||
delete file/folder | ||
``` | ||
$dropbox->delete('/Folder Name'); | ||
``` | ||
|
||
Response: | ||
``` | ||
[ | ||
'.tag' => 'folder', | ||
'name' => 'Folder Name', | ||
'path_lower' => '/folder name', | ||
'path_display' => '/Folder Name', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAAUg' | ||
] | ||
``` | ||
|
||
### move | ||
move file/folder to another path | ||
``` | ||
$dropbox->move($current_path, $move_to_path); | ||
``` | ||
### copy | ||
copy file/folder to another path | ||
``` | ||
$dropbox->copy($current_path, $move_to_path); | ||
``` | ||
### download file | ||
|
||
### get temporary link | ||
get temporary link of file | ||
``` | ||
$dropbox->getTemporaryLink('/path to file'); | ||
``` | ||
*currently in development* | ||
|
||
Response: | ||
``` | ||
[ | ||
'metadata' => [ | ||
'name' => 'file_name.zip', | ||
'path_lower' => '/file_name.zip', | ||
'path_display' => '/file_name.zip', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAACg', | ||
'client_modified' => '2016-02-20T17:59:59Z', | ||
'server_modified' => '2016-02-20T17:59:59Z', | ||
'rev' => '91f916734', | ||
'size' => (int) 218245, | ||
'content_hash' => '5e838e8a2dfa077c732e2aa95b2dbd2c0b549a96b728af36db84c5d17c899895' | ||
], | ||
'link' => 'https://dl.dropboxusercontent.com/apitl/1/...' | ||
] | ||
``` | ||
$drive->download('item_id'); | ||
### download file | ||
download file to specified path | ||
``` | ||
$dropbox->download('/file paht', $save_to); | ||
``` | ||
**save_to** is the local path of the file to save it. | ||
|
||
Example: `$dropbox->download('/file.zip', '/path/to/file.zip');` | ||
|
||
Response: Downloaded file information | ||
``` | ||
[ | ||
'name' => 'PHP_QR_Code_Generate.zip', | ||
'path_lower' => '/php_qr_code_generate.zip', | ||
'path_display' => '/PHP_QR_Code_Generate.zip', | ||
'id' => 'id:wDFg96ot7lwAAAAAAAAACg', | ||
'client_modified' => '2016-02-20T17:59:59Z', | ||
'server_modified' => '2016-02-20T17:59:59Z', | ||
'rev' => '91f916734', | ||
'size' => (int) 218245, | ||
'content_hash' => '5e838e8a2dfa077c732e2aa95b2dbd2c0b549a96b728af36db84c5d17c899895' | ||
] | ||
``` |