예제 #1
0
 public static RoyaltyRepository.Models.File FilePut(this RoyaltyRepository.Repository repository, IFileStorage storage, Stream streamToUpload, string fileName, Encoding encoding = null)
 {
     var repFile = repository.NewFile((f) =>
         {
             f.FileName = fileName;
             f.MimeType = MimeTypes.GetMimeTypeFromFileName(fileName);
         });
     var fileInfo = storage.FilePut(repFile.FileUID, streamToUpload, fileName);
     repFile.OriginalFileName = fileInfo.Name;
     repFile.FileSize = fileInfo.Length;
     repFile.Encoding = encoding;
     return repFile;
 }
예제 #2
0
        public static Repository.Model.File FilePut(this Repository.Logic.Repository repository, IFileStorage storage, Stream streamToUpload, string fileName, Encoding encoding = null)
        {
            var repFile = repository.New<Repository.Model.File>(f =>
            {
                f.Date = DateTime.UtcNow;
                f.FileId = Guid.NewGuid();
                f.FileName = fileName;
                f.MimeType = MimeStorage.GetMimeTypeByExtension(fileName);
            });

            var fileInfo = storage.FilePut(repFile.FileId, streamToUpload, fileName);
            repFile.UniqueFileName = fileInfo.Name;
            repFile.FileSize = fileInfo.Length;
            repFile.Encoding = encoding;
            return repFile;
        }