IPWorks Cloud 2020 macOS Edition

Questions / Feedback?

CopyBlob Method

Copies a blob.

Syntax

public func copyBlob(srcBlob: String, destBlob: String, destContainer: String) throws -> String

Remarks

This method copies the specified SrcBlob (in the container currently selected by Container) to the specified DestBlob in DestContainer. If this method finishes successfully, it will either return an asynchronous copy Id, or an empty string (if the copy has finished already).

If Snapshot is non-empty, the specified snapshot of SrcBlob will be used as the copy source. In this case, DestBlob may be the same blob as SrcBlob to "promote" the snapshot, copying its contents back to the base blob.

If DestContainer is empty, the current value of Container is used instead. If DestContainer in non-empty, the value will automatically be lowercased when preparing the request.

If DestBlob already exists, and is the same type of blob as SrcBlob, then it will be overwritten if Overwrite is enabled. However, any snapshots associated with the existing blob are retained.

If DestBlob already exists and has an active infinite-duration lease, its lease Id must be specified using LeaseId, or the request will fail. (If it exists and has an active fixed-duration lease, the request will always fail.)

If the SendMetadataOnCopy configuration setting is enabled when this method is called, all items in the Metadata* properties will be sent in the copy request and applied to DestBlob. Otherwise, the server will copy the metadata items from SrcBlob to DestBlob.

If the request succeeds, this method will always populate the CopyId and CopyStatus configuration settings (and clear CopyProgress and CopyStatusDesc).

Asynchronous Copy Notes

As mentioned, this method will return a copy operation Id if the copy operation was started asynchronously. In this case, use the GetBlobInfo method to poll the DestBlob blob's information, which will cause the CopyStatus, CopyStatusDesc, and CopyProgress configuration settings to be refreshed.

A copy operation whose CopyStatus is still pending may also be aborted by passing the copy operation Id returned by this method (or later retrieved from CopyId) to the AbortCopy method.

// Copy a blob to another location within the same container.
string copyResult = azureblob.CopyBlob("important.zip", "secrets.zip", "");

// If the returned value *isn't* empty string, then we'll monitor the status of the
// asynchronous copy operation by polling once every 2 seconds using GetBlobInfo().
if (!string.IsNullOrEmpty(copyResult)) {
  do {
    azureblob.GetBlobInfo("secrets.zip");
    Console.WriteLine("Copy progress: " + azureblob.Config("CopyProgress"));
  } while (azureblob.Config("CopyStatus") == "pending");
}

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 macOS Edition - Version 20.0 [Build 8265]