protected override void PerformUpload()
        {
            if (!Directory.Exists(Options.TemporaryDirectory))
            {
                Directory.CreateDirectory(Options.TemporaryDirectory);
            }

            var tempFile = Path.Combine(Options.TemporaryDirectory, Guid.NewGuid().ToString());

            try
            {
                ReliableCloudOperations.RetryRead(() => DownloadSource(tempFile));

                ReliableCloudOperations.RetryWrite(() =>
                {
                    if (Blob.Exists())
                    {
                        return;
                    }
                    Blob.UploadFromFile(
                        tempFile,
                        FileMode.Open,
                        options: Options.BlobRequestOptions,
                        accessCondition: AccessConditions.CreateIfNotExists());
                });
            }
            finally
            {
                File.Delete(tempFile);
            }
        }
Example #2
0
        public void Start(CloudBlockBlob target, CloudBlockBlob source)
        {
            source = EnsureAccessToSource(target, source);
            var copyId = target.StartCopyFromBlob(source, destAccessCondition: AccessConditions.CreateIfNotExists());

            _blobsToCopy.Add(new BlobCopyProgress(target, source, copyId));
        }
 protected override void PerformUpload()
 {
     _stream.EnsureAtStart();
     _stream = Store.Cache.Add(FileKey, _stream, Length);
     ReliableCloudOperations.RetryWrite(() =>
     {
         if (Blob.Exists())
         {
             return;
         }
         _stream.EnsureAtStart();
         Blob.UploadFromStream(
             _stream,
             options: Options.BlobRequestOptions,
             accessCondition: AccessConditions.CreateIfNotExists());
     });
 }