flysystem-azure-blob-storage icon indicating copy to clipboard operation
flysystem-azure-blob-storage copied to clipboard

Issues with copying files within the Azure container

Open DylanDonkersgoed opened this issue 5 years ago • 1 comments

I'm having issues where when a file is copied from one Azure Blob file stream URI to another via the PHP copy function the newly created file is empty.

So, e.g., say I have a file at http://127.0.0.1:10000/devstoreaccount1/test/somefolder/searchtest2.docx represented in my application as azblob://somefolder/searchtest2.docx and want to copy it to http://127.0.0.1:10000/devstoreaccount1/test/someotherfolder/searchtest2.docx represented as azblob://someotherfolder/searchtest2.docx. So I do the following to copy it:

copy('azblob://somefolder/searchtest2.docx', 'http://127.0.0.1:10000/devstoreaccount1/test/someotherfolder/searchtest2.docx')

but the destination file is always 0B, though I don't see any errors logged or anything.

Should this work? I can write files from the filesystem to blob storage and read files from blob storage. From what I can tell debugging it it ends up in a lot of the same places. E.g. it reads files in readStream just like it does in other working calls and I can see with stream_get_contents() that the stream has data in it. And it ends up at writeStream just like other working calls. But at some point before it gets to writeStream() the resource for the source file is empty. And I cannot figure out why this happens.

In my debugger the code seems to jump straight from the copy call into https://github.com/thephpleague/flysystem-azure/blob/master/src/AzureAdapter.php which I'm a bit suspicious of (I don't understand why that happens, but honestly I don't really understand PHP filestreams that well) but it makes me fairly confident the issue is not in the code directly calling the copy() function at least.

DylanDonkersgoed avatar Oct 23 '20 13:10 DylanDonkersgoed

The issue seems to be an interaction between this library and https://github.com/twistor/flysystem-stream-wrapper. See https://github.com/twistor/flysystem-stream-wrapper/issues/21 for more details.

DylanDonkersgoed avatar Oct 23 '20 14:10 DylanDonkersgoed