通过PHP API将多种文件上传到Dropbox

问题描述 投票:1回答:1

我试图使用Dropbox PHP Api上传文件。 它的工作完美。 Dropbox api中是否有用于多个文件上传的选项。 还是php中有任何异步上传的概念? 。 目前,我正在使用oauth2.0进行应用登录。

 /**
 * 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');
}

我正在使用的脚本

dropbox dropbox-api dropbox-php
1个回答
1
投票

Dropbox API当前不提供任何批量或批量上传功能,但我们正在将其作为功能请求进行跟踪。

在这种情况下,如果要以异步方式运行此代码,可以通过在另一个线程的后台运行它来实现。 还有其他相关文章,例如:

© www.soinside.com 2019 - 2024. All rights reserved.