Exemplo n.º 1
0
 public static AWSConnectionService getInstance()
 {
     if (singletonInstance != null)
     {
         return(singletonInstance);
     }
     else
     {
         singletonInstance = new AWSConnectionService();
         return(singletonInstance);
     }
 }
Exemplo n.º 2
0
 public async Task UploadFileAsync(string emailId)
 {
     try
     {
         var uploadRequest = new TransferUtilityUploadRequest
         {
             FilePath   = filePath,
             BucketName = bucketName,
             Key        = keyName,
             CannedACL  = S3CannedACL.PublicRead
         };
         var fileTransferUtility = new TransferUtility(s3Client);
         await Task.Run(() =>
         {
             Task upld = fileTransferUtility.UploadAsync(uploadRequest);
             while (!upld.IsCompleted)
             {
                 upld.Wait(25); if (upld.IsFaulted || upld.IsCanceled)
                 {
                     return;
                 }
             }
             Trace.WriteLine(String.Format("Upload status: {0} \n Upload Complete: {1}", upld.Status, upld.IsCompleted));
             AWSConnectionService.getInstance().ListPDFFilesforUser(emailId);
             Console.WriteLine("File Upload completed.. Check bucket via console");
             Application.Current.Dispatcher.Invoke((Action) delegate
             {
                 new Welcome(emailId).Show();
             });
         });
     }
     catch (AmazonS3Exception e)
     {
         Trace.WriteLine(String.Format("Error encountered on server. Message: '{0}' when writing an object", e.Message));
     }
     catch (Exception e)
     {
         Trace.WriteLine(String.Format("Unknown encountered on server. Message: '{0}' when writing an object", e.Message));
     }
 }