使用Dropbox API将文件直接传输到远程FTP服务器,无需下载中间文件

I have large design files (up to 500 MB) on Dropbox, and I'm building a tool to transfer a single file programmatically to a vendor's FTP server in our online PHP-based project management program. Because of the file size, I don't want to download the file to the server, then upload that file to the FTP server, due to both speed and storage space issues.

I can use the following Dropbox API call:

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.

And I'm guessing I can use the following PHP command:

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.

I don't have any experience with file data streams, so I have no idea how to connect the two. After a couple of hours of online searching, I figured I'd try asking here.

How do I connect getFile's $outstream resource with ftp_fput's $ftp_stream resource?

Spent half the day experimenting with this, and finally got it to work. The solution involves using the PHP data:// scheme to create a stream in memory, then rewinding that stream to send it to the FTP server. Here's the gist of it:

// open an FTP connection
$ftp_connection = ftp_connect('ftp.example.com');
ftp_login($ftp_connection,'username','password');

// get the file mime type from Dropbox, to create the correct data stream type
$metadata = $dopbox->getMetadata($file) // $dropbox is authenticated connection to Dropbox Core API; $file is a complete file path in Dropbox
$mime_type = $metadata['mime_type'];

// now open a data stream of that mime type
// for example, for a jpeg file this would be "data://image/jpeg"
$stream = fopen('data://' .mime_type . ',','w+'); // w+ allows both writing and reading
$dropbox->getFile($file,$stream); // loads the file into the data stream
rewind($stream)
ftp_fput($ftp_connection,$remote_filename,$stream,FTP_BINARY); // send the stream to the ftp server

// now close everything
fclose($stream);
ftp_close($ftp_connection);