how to copy a locally created file to azure file storage using PHP

rodolfo tuble 1 Reputation point
2020-06-08T15:17:09.417+00:00

I'm trying to follow this link: https://learn.microsoft.com/en-us/rest/api/storageservices/copy-file with examples from this repo: https://github.com/Azure/azure-storage-php/blob/master/samples/FileSamples.php#L235 The file is indeed copied to the azure server but the content aren't readable, to say the least, it takes a size but it's empty. This is only a text file as well, and what I plan to achieve after fixing this is to copy excel files generated via PHP to an azure file storage server.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,347 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,366 Reputation points
    2020-06-09T00:14:52.187+00:00

    Hi @rodolfotuble-4323,

    Are you getting any error messages or confirmation message that the file has been copied to the Azure server? When you say "not readable " what does that mean? you should get a 202 status code if the copy was successful.

    A few things to keep in mind:

    -If the destination file exists, it will be overwritten. The destination file cannot be modified while the copy operation is in progress.

    -The Copy File operation always copies the entire source blob or file; copying a range of bytes or set of blocks is not supported

    -The destination file is always the same size as the source blob or file, so the value of the Content-Length header for the destination file matches that for the source blob or file.

    Hope that helps.

    -Grace