简体   繁体   中英

How can i Download file to local directly from Dropbox API

I m using https://github.com/kunalvarma05/dropbox-php-sdk this library in my laravel project .From this code this "example.txt" file downloaded in my project directory. But i want to download this "example.txt" file with my browser into browser download folder.

    $file = $dropbox->download("/example.txt");
    $contents = $file->getContents();
    $metadata = $file->getMetadata();
    file_put_contents(__DIR__ . "/example.txt", $contents);

A little use with Google and found it for you.

$file = $dropbox->download("/my-logo.png");
//File Contents
$contents = $file->getContents();
//Save file contents to disk
file_put_contents(__DIR__ . "/logo.png", $contents);
//Downloaded File Metadata
$metadata = $file->getMetadata();
//Name
$metadata->getName();

link to examples and github: https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Upload-and-Download-Files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM