Пример #1
0
 public async Task <bool> UploadFile(UploadFileName uploadFileName)
 {
     try
     {
         var path = Path.Combine("Files", uploadFileName.ToString() + ".png");
         using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
         {
             string fileExtension = Path.GetExtension(path);
             string fileName      = $"{DateTime.Now.Ticks}{fileExtension}";
             return(await _awss3BucketHelper.UploadFile(fileStream, fileName));
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Пример #2
0
 public async Task <bool> UploadFile(string bucketName, UploadFileName uploadFileName)
 {
     try
     {
         var path = Path.Combine("Files", uploadFileName.ToString() + ".png");
         using (FileStream fsSource = new FileStream(path, FileMode.Open, FileAccess.Read))
         {
             string fileExtension = Path.GetExtension(path);
             string fileName      = string.Empty;
             fileName = $"{DateTime.Now.Ticks}{fileExtension}";
             return(await _AWSS3BucketHelper.UploadFile(fsSource, bucketName, fileName));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }