Exemplo n.º 1
0
 public S3(string connectionStringOrAppSettingName)
 {
     S3ConnectionString connStr;
     if (S3ConnectionString.TryParse(connectionStringOrAppSettingName, out connStr))
     {
         _connectionInfo = connStr;
     }
     else
     {
         _connectionInfo = ConfigUtilities.GetS3ConnectionString(connectionStringOrAppSettingName);
     }
 }
Exemplo n.º 2
0
        public static bool TryParse(string s, out S3ConnectionString connStr)
        {
            var match = Regex.Match(s, Pattern);

            if (match.Success)
            {
                connStr = Parse(s);
                return true;
            }
            connStr = S3ConnectionString.Empty;
            return false;
        }
Exemplo n.º 3
0
 public static void DownloadFiles(S3ConnectionString connectionInfo, string savePath, bool remveFromS3AfterDownload,
     Action<GetObjectResponse> onFileDownloaded = null, Action<DeleteObjectResponse> onFileDeleted = null)
 {
     DownloadFiles(connectionInfo.AccessKey, connectionInfo.SecretKey, connectionInfo.BucketName,
         connectionInfo.FolderName, savePath, remveFromS3AfterDownload, onFileDownloaded, onFileDeleted);
 }
Exemplo n.º 4
0
 public S3(S3ConnectionString connectionString)
 {
     _connectionInfo = connectionString;
 }
Exemplo n.º 5
0
 public static ListObjectsResponse ListFiles(S3ConnectionString connectionString)
 {
     return ListFiles(connectionString.AccessKey, connectionString.SecretKey, connectionString.BucketName,
         connectionString.FolderName);
 }
Exemplo n.º 6
0
        public static long GetTotalFileCount(S3ConnectionString connectionInfo)
        {
            using (var client = new AmazonS3Client(connectionInfo.AccessKey, connectionInfo.SecretKey,
                    new AmazonS3Config {ServiceURL = "http://s3.amazonaws.com"}))
            {
                var listObjectsRequest = new ListObjectsRequest
                {
                    BucketName = connectionInfo.BucketName,
                    Prefix = connectionInfo.FolderName
                };

                var marker = default(string);
                var totalCount = 0;

                var resp = default(ListObjectsResponse);
                do
                {
                    listObjectsRequest.Marker = marker;
                    resp = client.ListObjects(listObjectsRequest);
                    totalCount += resp.S3Objects.Count;

                    marker = resp.NextMarker;
                } while (resp.IsTruncated);

                return totalCount;
            }
        }