【发布时间】:2015-03-07 10:10:46
【问题描述】:
我在 Dropbox 上有大型设计文件(最大 500 MB),我正在构建一个工具,用于在我们基于 PHP 的在线项目管理程序中以编程方式将单个文件传输到供应商的 FTP 服务器。由于文件大小,我不想将文件下载到服务器,然后将该文件上传到 FTP 服务器,因为速度和存储空间问题。
我可以使用以下 Dropbox API 调用:
getFile( string $path, resource $outStream, string|null $rev = null )
Downloads a file from Dropbox. The file's contents are written to the given $outStream and the file's metadata is returned.
我猜我可以使用以下 PHP 命令:
ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos = 0 ] )
Uploads the data from a file pointer to a remote file on the FTP server.
我对文件数据流没有任何经验,所以我不知道如何将两者联系起来。经过几个小时的在线搜索,我想我会尝试在这里询问。
如何将 getFile 的 $outstream 资源与 ftp_fput 的 $ftp_stream 资源连接起来?
【问题讨论】:
-
我还没有尝试过,但也许 stream_copy_to_stream 可以完成这项工作? php.net/manual/en/function.stream-copy-to-stream.php
-
@Greg,好主意,但没用。但是,您确实为我指明了正确的方向。我很感激。
标签: php ftp dropbox data-stream