Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

Dropbox API with PHP get content of file in Dropbox

I have a WebApp that stores a backup in the cloud of the user. I use the third party libary: http://fabi.me/en/php-projects/dropphp-dropbox-api-client/

Login works. But im stuck at the point where I can download it.

The following code downloads the file on the cloud and writes it to a file.

$dropbox->DownloadFile( $file, $test_file )

But I need the content of the file only in a string and not as file. The data shouldn't be stored.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Out of the box, you can't. However, the DownloadFile method is quite simple: https://github.com/f4bsch/DropPHP/blob/master/DropboxClient.php#L261

My suggestion is to override this method by creating your own, CustomDropboxClient by extending the used DropboxClient library, then rewrite the file handling logic. It's using the curl library. By setting the CURLOPT_RETURNTRANSFER option, you can retrieve the data without writing it to a file.

This should give you enough hints to start this project. If you need anything, just comment.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...