dtz88967 2015-04-14 13: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 10: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

    评论

报告相同问题?