Reputation: 1508
I am using Azure Storage Nodejs
and what i need to do is to copy image from one blob to another.
First i tried to getBlobToFile
to get the image on temp location in disk and then just createBlockBlobFromFile
from that temp location. That method did the task, but for some reason it didn't copied completely in 10% of cases.
The i was trying to use getBlobToText
and the result of that put into createBlockBlobFromText
, also tried to put options which is need blob to be image container. That method failed completely, image not even opened after copy.
Perhaps there is a way to copy blob file and paste it in other blobl but i didn't find that method.
What else can i do?
Upvotes: 1
Views: 2261
Reputation: 2294
The link in the accepted answer is broken, although the method is correct: the method startCopyBlob
is documented here
(Updated: Jan 3, 2020) https://learn.microsoft.com/en-us/javascript/api/azure-storage/BlobService?view=azure-node-latest#azure_storage_BlobService_createBlockBlobFromLocalFile
Upvotes: 0
Reputation: 71035
I'm not sure what your particular copy-error is, but... with getLocalBlobToFile()
, you're actually physically moving blob content from blob storage to your VM (or local machine), and then with createBlockBlobFromLocalFile()
you're pushing the entire contents back to blob storage, which is resulting in two physical network moves.
The Azure Storage system supports blob-copy as a 1st-class operation. While it's available via REST API call, it's also wrapped in the same SDK you're using, in the method BlobService.startCopyBlob()
(source code here). This will instruct the storage to initiate an async copy operation, completely within the storage system (meaning no download+upload on your side). You'll be able to set source and destination, set timeouts, etc. (all parameters are fully documented in the source code).
Upvotes: 6