Skip to content

Upload and Download Files

Kunal Varma edited this page Jun 30, 2016 · 9 revisions

Upload and Download Files

Upload File by URL

Save URL

Save a specified URL into a file in user's Dropbox.

Example

$asyncJobID = $dropbox->saveUrl("/my-logo.png", 'http://mywebsite.com/wp-content/uploads/2016/06/logo.png');

The saveUrl() method will return a asyncJobID (Async Job ID). The asyncJobID string is an id that can be used to obtain the status of the asynchronous job using the checkJobStatus method.

For available options see: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-save_url

Check Job Status

Check the status of a saveUrl job.

Example

$asyncJobID = $dropbox->saveUrl("/my-logo.png", 'http://mywebsite.com/wp-content/uploads/2016/06/logo.png');

//Check Status
$status = $dropbox->checkJobStatus($asyncJobID);

//Job Successful. File saved.
if ($status instanceof FileMetadata) {
    $file = $status;
    echo $file->getName();
} elseif ($status === "in_progress") {
    echo "Processing job...";
} elseif ($status === "failed") {
    echo "Job Failed!";
} else {
    echo $status;
}

The checkJobStatus() method will either return the FileMetadata of the saved file upon success or the job status, which could be either in_progress or failed.

For available options see: https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-save_url-check_job_status

Clone this wiki locally