Php Curl Request to upload file on the azurefile

mohit sharma 21 Reputation points
2020-12-04T05:54:50.247+00:00

I am using php5.3 and most libraries do not support php5.3 so I plan to use curl request to upload or receive files from azure file service (not blob). Can anyone send a sample code for this?

I got a reference from microsoft document to call the rest of api but I am getting error below:`<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:0f929eec-b01a-005d-4e00-ca5362000000
Time:2020-12-04T05:47:30.0080306Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'XXX' is not the same as any computed signature. Server used following string to sign: 'PUT

446422

text/plain; charset=UTF-8

x-ms-content-length:1024
x-ms-date:Fri, 04 Dec 2020 05:47:28 GMT
x-ms-version:2020-02-10
/hsdirectfilestorage/hsdirectfileshare/pdf/12345.png'.</AuthenticationErrorDetail></Error>Error<br/>`

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,420 questions
{count} votes

Accepted answer
  1. deherman-MSFT 38,021 Reputation points Microsoft Employee Moderator
    2020-12-04T19:40:34.64+00:00

    @mohit sharma
    We have the Azure Storage Library for PHP but this requires PHP 5.6 or above. To upload to Azure Files via REST API two calls are required. First you need to Create File. Once the file has been successfully created you use Put Range to add the contents. For some examples you might want to refer to this blog post.

    Hope this helps! Please let us know if you have further questions or issues.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.