dtz88967 2015-04-14 05:21
浏览 104

使用Azure PHP SDK从Azure Blob Storage下载blob文件

I am using the Azure PHP SDK to download a blob into a local file. I am using the following code but struggling to produce the actual file on disk. How can indicate where to download the file (folder)?

Is there anything wrong with this code?

Thanks

$blobfile = "123.vox";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);

    $blob = $blobRestProxy->getBlob("containerName", $blobfile);

    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"$blobfile\"");
    fpassthru($blob->getContentStream());
  • 写回答

1条回答 默认 最新

  • dongnuo3749 2015-04-21 02:54
    关注

    try something like this:

    $blobfile = "123.vox";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
    
    $blob = $blobRestProxy->getBlob("containerName", $blobfile);
    $source = stream_get_contents($blob->getContentStream());
    $localPath = '/var/www/path/to/my/downloaded/file';
    $result = file_put_contents($localPath, $source);
    

    HTH,

    Susanne

    评论
    编辑
    预览

    报告相同问题?

    手机看
    程序员都在用的中文IT技术交流社区

    程序员都在用的中文IT技术交流社区

    专业的中文 IT 技术社区,与千万技术人共成长

    专业的中文 IT 技术社区,与千万技术人共成长

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    客服 返回
    顶部