コード例 #1
0
        public Bitmap GetS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
        {
            try
            {
                var objectResponse = (GetAmazonS3Client()).GetObject(currentConnectionProfile.BucketName, currentS3MediaSelected.Key);
                var bitmap         = DataAccessHelper.GetBitmapFromByteArray(S3ObjectToByteArray(objectResponse).ToArray());

                return(bitmap);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
コード例 #2
0
 private void UpdateCurrentS3MediaSelected(S3MediaEntity sender)
 {
     try
     {
         var record = (sender);
         var item   = record.Key;
         CurrentS3MediaSelected = record;
         AddUserMessage($"Media file {item} selected");
         lblLoadPictureFromAmazonS3.Text = $@"{record.Key}";
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
コード例 #3
0
        /// <summary>
        /// Gets a list of object Keys when given the specified parameters. Please note that the maximum value of takeXRecords is determined by the bucket setup.
        /// </summary>
        /// <param name="currentConnectionProfile">Contains the profile information driving the type of connection we will use with Amazon S3.</param>
        /// <param name="takeXRecords">Specifies how many records to pull. This might be limited to 1000 records, as set up in the Amazon account.</param>
        /// <returns>A list of entity S3MediaEntity, where the Key is probably the most important data used.</returns>
        public List <S3MediaEntity> GetS3MediaList(S3ConnectionProfileEntity currentConnectionProfile, int takeXRecords)
        {
            try
            {
                var s3Client           = GetAmazonS3Client();
                var listObjectsRequest = new ListObjectsRequest
                {
                    MaxKeys    = takeXRecords,
                    BucketName = currentConnectionProfile.BucketName,
                    Prefix     = currentConnectionProfile.FolderName
                };

                var files     = s3Client.ListObjects(listObjectsRequest);
                var mediaList = new List <S3MediaEntity>();

                foreach (var record in files.S3Objects)
                {
                    if (record.Key.Contains("_$folder$"))
                    {
                        continue;
                    }
                    var media = new S3MediaEntity()
                    {
                        ProfileName = currentConnectionProfile.ProfileName,
                        BucketName  = currentConnectionProfile.BucketName,
                        FolderName  = currentConnectionProfile.FolderName,
                        Key         = record.Key
                    };
                    mediaList.Add(media);
                }

                return(mediaList);
            }
            catch (Exception exception)
            {
                throw new SystemException(exception.Message);
            }
        }
コード例 #4
0
 public void DeleteS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 public static void DeleteS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         if (currentConnectionProfile.KeyBasedAccessFlag)
         {
             (new AmazonS3V2.DAL.S3Access()).DeleteS3Media(currentConnectionProfile, currentS3MediaSelected);
         }
         else
         {
             (new AmazonS3V3.DAL.S3Access()).DeleteS3Media(currentConnectionProfile, currentS3MediaSelected);
         }
     }
     catch (Exception exception)
     {
         throw new Exception($"Error {exception.Message}");
     }
 }
コード例 #6
0
 public static Bitmap GetS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         if (currentConnectionProfile.KeyBasedAccessFlag)
         {
             return((new AmazonS3V2.DAL.S3Access()).GetS3Media(currentConnectionProfile, currentS3MediaSelected));
         }
         else
         {
             return((new AmazonS3V3.DAL.S3Access()).GetS3Media(currentConnectionProfile, currentS3MediaSelected));
         }
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
コード例 #7
0
 private Bitmap GetS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         return(S3Library.GetS3Media(currentConnectionProfile, currentS3MediaSelected));
     }
     catch (Exception exception)
     {
         AddUserMessage(exception.Message);
         return(null);
     }
 }
コード例 #8
0
        private void UpdateLoadedS3Image(S3ConnectionProfileEntity connectionProfileEntity, S3MediaEntity mediaEntity)
        {
            var s3Media = GetS3Media(connectionProfileEntity, mediaEntity);

            amazonLoadedPicture.Image = s3Media;
        }
コード例 #9
0
 public void DeleteS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         var client = GetAmazonS3Client(currentConnectionProfile);
         client.DeleteObject(currentConnectionProfile.BucketName, currentS3MediaSelected.Key);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
コード例 #10
0
 public static void DeleteS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         DataAccess.DeleteS3Media(currentConnectionProfile, currentS3MediaSelected);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
コード例 #11
0
 public static Bitmap GetS3Media(S3ConnectionProfileEntity currentConnectionProfile, S3MediaEntity currentS3MediaSelected)
 {
     try
     {
         return(DataAccess.GetS3Media(currentConnectionProfile, currentS3MediaSelected));
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }