示例#1
0
        public static CopyTemporaryFileResult CopyTemporaryFile(this IUploadStorage uploadStorage,
                                                                CopyTemporaryFileOptions options)
        {
            if (uploadStorage is null)
            {
                throw new ArgumentNullException(nameof(uploadStorage));
            }

            long   size = uploadStorage.GetFileSize(options.TemporaryFile);
            string path = PathHelper.ToUrl(UploadFormatting.FormatFilename(options));

            path = uploadStorage.CopyFrom(uploadStorage, options.TemporaryFile, path, autoRename: true);
            bool hasThumbnail = uploadStorage.FileExists(UploadPathHelper.GetThumbnailName(options.TemporaryFile));

            var result = new CopyTemporaryFileResult()
            {
                FileSize     = size,
                Path         = path,
                OriginalName = options.OriginalName,
                HasThumbnail = hasThumbnail
            };

            options.FilesToDelete?.RegisterNewFile(path);
            options.FilesToDelete?.RegisterOldFile(options.TemporaryFile);
            return(result);
        }
示例#2
0
 public void Register(CopyTemporaryFileResult result)
 {
     RegisterNewFile(result.FilePath);
     RegisterOldFile(result.TemporaryFilePath);
 }