如何使用PHP使用共享访问签名在Azure中上传blob?

时间:2016-08-31 05:18:52

标签: php azure azure-storage-blobs

我正在使用azure php SDK,我现在从应用程序获得了SAS签名,如何使用SAS(共享访问签名)将文件上传到blob。

2 个答案:

答案 0 :(得分:1)

如果您拥有SAS令牌,并且它具有Azure存储帐户中blob的写入权限,则可以利用SAS令牌将文件直接上载到Azure存储而不使用Azure Storage SDK for PHP。

我假设你有正确的带有签名的SAS查询字符串,它应该类似于: <textarea type="text" class="form-control" name="es_version" > <?php echo $_GET["version"]; ?> </textarea>

然后,您利用?sv=2015-04-05&ss=bt&srt=sco&sp=w&st=2016-09-01T01%3A54%3A00Z&se=2016-09-02T01%3A54%3A00Z&sig=AQ%2F1yL8bt0AQzoYwtQmTUR6UKkJPC4PXg%2BxysdlkMoE%3D创建对Azure存储的REST API请求以上传您的文件,

cUrl

有关将Blob放入Azure存储的REST API的更多详细信息,请参阅https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx

答案 1 :(得分:0)

Our PHP tutorial for blobs shows how to create a connection string and then upload a blob.

You can use the SAS as the credentials for your connection string. The connection string format is (line breaks included for readability only):

BlobEndpoint=myBlobEndpoint;
QueueEndpoint=myQueueEndpoint;
TableEndpoint=myTableEndpoint;
FileEndpoint=myFileEndpoint;
SharedAccessSignature=sasToken

Please see Create a connection string using a shared access signature for more information and examples.