Пример #1
0
        private void putStorageItem(string containerName, Stream storageStream, string remoteStorageItemName, Dictionary<string, string> metadata, EventHandler<UploadProgress> callback, Object context)
        {
            var putStorageItem = new PutStorageItem(StorageUrl, containerName, remoteStorageItemName, storageStream, metadata);
            if (callback != null)
            {
                UploadProgress eventArgs = new UploadProgress((UInt64)storageStream.Length, this, callback, context)
                {
                    MaxBytesTxDeltaFreq = this.MaxBytesTxDeltaFreq,
                    MaxCallbackFreq = this.MaxCallbackFreq,
                    MinBytesTxDeltaFreq = this.MinUploadBytesTxDeltaFreq
                };

                putStorageItem.Progress += (x) => { eventArgs.OnProgress(x); };
            }

            // add the general upload progress handlers
            foreach (var storedCallback in _callbackFuncs)
            {
                putStorageItem.Progress += storedCallback;
            }

            _requestfactory.Submit(putStorageItem, AuthToken, _usercreds.ProxyCredentials);
        }
Пример #2
0
        private void putStorageItem(string containerName, string localFilePath, Dictionary<string, string> metadata, EventHandler<UploadProgress> callback, Object context)
        {
            UInt64 filesize = 0;
            using (FileStream file = new FileStream(localFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                filesize = (UInt64)file.Length;
            }

            var remoteName = Path.GetFileName(localFilePath);
            var localName = localFilePath.Replace("/", "\\");
            var putStorageItem = new PutStorageItem(StorageUrl, containerName, remoteName, localName, metadata);

            if (callback != null)
            {
                // add the caller's upload specific upload progress handler
                UploadProgress eventArgs = new UploadProgress(filesize, this, callback, context)
                {
                    MaxBytesTxDeltaFreq = this.MaxBytesTxDeltaFreq,
                    MaxCallbackFreq = this.MaxCallbackFreq,
                    MinBytesTxDeltaFreq = this.MinUploadBytesTxDeltaFreq
                };

                putStorageItem.Progress += (x) => { eventArgs.OnProgress(x); };
            }

            // add the general upload progress handlers
            foreach (var storedCallback in _callbackFuncs)
            {
                putStorageItem.Progress += storedCallback;
            }

            _requestfactory.Submit(putStorageItem, AuthToken, _usercreds.ProxyCredentials);
        }