/// <summary> /// upload file to azure blob /// </summary> /// <param name="taskId">Task id</param> /// <param name="filePath">local file path</param> /// <param name="blob">destination azure blob object</param> internal virtual async Task Upload2Blob(long taskId, IStorageBlobManagement localChannel, string filePath, StorageBlob.ICloudBlob blob) { string activity = String.Format(Resources.SendAzureBlobActivity, filePath, blob.Name, blob.Container.Name); string status = Resources.PrepareUploadingBlob; ProgressRecord pr = new ProgressRecord(OutputStream.GetProgressId(taskId), activity, status); DataMovementUserData data = new DataMovementUserData() { Data = blob, TaskId = taskId, Channel = localChannel, Record = pr }; BlobUploadJob uploadJob = new BlobUploadJob() { DestBlob = blob, SourcePath = filePath }; await this.RunTransferJob(uploadJob, data); if (this.BlobProperties != null || this.BlobMetadata != null) { await TaskEx.WhenAll( this.SetBlobProperties(localChannel, blob, this.BlobProperties), this.SetBlobMeta(localChannel, blob, this.BlobMetadata)); } try { await localChannel.FetchBlobAttributesAsync( blob, AccessCondition.GenerateEmptyCondition(), this.RequestOptions, this.OperationContext, this.CmdletCancellationToken); } catch (StorageException e) { //Handle the limited read permission. if (!e.IsNotFoundException()) { throw; } } WriteICloudBlobObject(data.TaskId, localChannel, blob); }
/// <summary> /// upload file to azure blob /// </summary> /// <param name="taskId">Task id</param> /// <param name="filePath">local file path</param> /// <param name="blob">destination azure blob object</param> internal virtual async Task<bool> Upload2Blob(long taskId, IStorageBlobManagement localChannel, string filePath, ICloudBlob blob) { string activity = String.Format(Resources.SendAzureBlobActivity, filePath, blob.Name, blob.Container.Name); string status = Resources.PrepareUploadingBlob; ProgressRecord pr = new ProgressRecord(OutputStream.GetProgressId(taskId), activity, status); DataMovementUserData data = new DataMovementUserData() { Data = blob, TaskId = taskId, Channel = localChannel, Record = pr }; BlobUploadJob uploadJob = new BlobUploadJob() { DestBlob = blob, SourcePath = filePath }; this.EnqueueTransferJob(uploadJob, data); return await data.taskSource.Task; }