【问题标题】:Download File as bytearray using FILE STORAGE AZURE使用 FILE STORAGE AZURE 将文件下载为字节数组
【发布时间】:2018-10-04 03:43:48
【问题描述】:

使用 php 作为字节数组从 Azure 下载文件的 PHP 等效项是什么? 用于文件存储。 这是在 C# 和 blob 中完成的:

CloudBlockBlob blob = 
cloudBlobContainer.GetBlockBlobReference(targetFileName);
blob.FetchAttributes();
long fileByteLength = blob.Properties.Length;
Byte[] myByteArray = new Byte[fileByteLength];
blob.DownloadToByteArray(myByteArray, 0);

谢谢

【问题讨论】:

    标签: c# php azure-storage azure-blob-storage azure-files


    【解决方案1】:

    你可以在这里找到很多例子:Github: Azure/azure-storage-php

    喜欢这个:

    function downloadBlobSample($blobClient)
    {
        try {
            $getBlobResult = $blobClient->getBlob("mycontainer", "myblob");
        } catch (ServiceException $e) {
            $code = $e->getCode();
            $error_message = $e->getMessage();
            echo $code.": ".$error_message.PHP_EOL;
        }
    
        file_put_contents("output.txt", $getBlobResult->getContentStream());
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-05
      • 1970-01-01
      • 2017-06-04
      相关资源
      最近更新 更多