1

I was tried to upload files using Dropbox PHP Api . its worked perfectly . Is there any option in Dropbox api for multiple file uploads . or any asynchronous uploading concept is there in php ? . Currently i am using oauth2.0 for app signin .

 /**
 * Uploads a physical file from disk
 * Dropbox impose a 150MB limit to files uploaded via the API. If the file
 * exceeds this limit or does not exist, an Exception will be thrown
 * @param  string      $file      Absolute path to the file to be uploaded
 * @param  string|bool $filename  The destination filename of the uploaded file
 * @param  string      $path      Path to upload the file to, relative to root
 * @param  boolean     $overwrite Should the file be overwritten? (Default: true)
 * @return object      stdClass
 */
public function putFile($file, $filename = false, $path = '', $overwrite = true)
{
    if (file_exists($file)) {
        if (filesize($file) <= 157286400) {
            $call = 'files/' . $this->root . '/' . $this->encodePath($path);
            // If no filename is provided we'll use the original filename
            $filename = (is_string($filename)) ? $filename : basename($file);
            $params = array(
                'filename' => $filename,
                'file' => '@' . str_replace('\\', '/', $file) . ';filename=' . $filename,
                'overwrite' => (int) $overwrite,
            );

            return $this->fetch('POST', self::CONTENT_URL, $call, $params);

        }
        throw new Exception('File exceeds 150MB upload limit');
    }

    // Throw an Exception if the file does not exist
    throw new Exception('Local file ' . $file . ' does not exist');
}

This script i am using

1 Answers1

1

The Dropbox API does not currently offer any bulk or batch uploading, but we're tracking this as a feature request.

That being the case, if you want to run this code in an async fashion, you can do so by running it in the background on another thread. There are other posts that cover this, e.g.:

Greg
  • 16,359
  • 2
  • 34
  • 44
  • Thanks for your answer Greg – Babu Siva M May 28 '15 at 06:46
  • Hey @Greg. how about now? is there a multiple file upload already? – Hike Nalbandyan Mar 02 '20 at 23:08
  • 1
    @HikeNalbandyan There still isn't a Dropbox API option for uploading multiple different files at once in one call, but there is a way to set up multiple upload sessions and then commit them at once, which can be useful in certain use cases: https://www.dropbox.com/developers/reference/data-ingress-guide – Greg Mar 02 '20 at 23:41