Пример #1
0
 public UploadSaveResult(string uploadFileName, string uploadFileMediaType, ISaveResult result)
     : this(uploadFileName, uploadFileMediaType) {
     Contract.NotNull(result, nameof(result));
     
     this.Success = result.Success;
     this.Exception = result.Exception;
     this.errorMessage = result.GetErrorMessage();
     this.Key = result.Key;
     this.AlreadyExists = result.AlreadyExists;
 }
Пример #2
0
        public UploadSaveResult(string uploadFileName, string uploadFileMediaType, ISaveResult result)
            : this(uploadFileName, uploadFileMediaType)
        {
            Contract.NotNull(result, nameof(result));

            this.Success       = result.Success;
            this.Exception     = result.Exception;
            this.errorMessage  = result.GetErrorMessage();
            this.Key           = result.Key;
            this.AlreadyExists = result.AlreadyExists;
        }
Пример #3
0
        private async Task <IMoveResult> MoveAndOverwrite(string sourceKey, string destKey, FileSystemCabinetConfig config)
        {
            try {
                ISaveResult saveResult = null;

                // Close stream as soon as we have a result
                using (var stream = await this.OpenReadStreamAsync(sourceKey, config)) {
                    saveResult = await this.SaveFileAsync(destKey, stream, HandleExistingMethod.Overwrite, null, config);
                }

                if (!saveResult.Success)
                {
                    return(new MoveResult(sourceKey, destKey, success: false, errorMsg: saveResult.GetErrorMessage()));
                }

                var deleteResult = await this.DeleteFileAsync(sourceKey, config);

                if (!deleteResult.Success)
                {
                    return(new MoveResult(sourceKey, destKey, success: false, errorMsg: deleteResult.GetErrorMessage()));
                }

                return(new MoveResult(sourceKey, destKey));
            } catch (Exception e) {
                return(new MoveResult(sourceKey, destKey, e));
            }
        }