コード例 #1
0
        public void TestStandardAwsStuff()
        {
            ListObjectsRequest request = new ListObjectsRequest()
            {
                BucketName = temp_bucket,
                Prefix     = "folder1/sub2/",
                Delimiter  = "/",
                MaxKeys    = 1
            };

            client.ListObjects(request);

            InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest()
            {
                BucketName = temp_bucket,
                Key        = "mpu-1",
            };

            InitiateMultipartUploadResponse initResponse = client.InitiateMultipartUpload(initRequest);

            client.AbortMultipartUpload(new AbortMultipartUploadRequest()
            {
                BucketName = temp_bucket,
                Key        = "mpu-1",
                UploadId   = initResponse.UploadId
            });
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            // create the ECS S3 client
            ECSS3Client s3 = ECSS3Factory.getS3Client();

            // create bucket request
            PutBucketRequestECS request = new PutBucketRequestECS()
            {
                BucketName = ECSS3Factory.S3_BUCKET
            };

            // create bucket - used for subsequent demos
            s3.PutBucket(request);

            // create bucket lising request
            ListObjectsRequest objects = new ListObjectsRequest()
            {
                BucketName = ECSS3Factory.S3_BUCKET
            };

            // get bucket lising to retrieve bucket name
            ListObjectsResponse result = s3.ListObjects(objects);

            // print bucket name for validation
            Console.WriteLine(string.Format("Successfully created bucket {0}.", result.Name));
            Console.ReadLine();
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            // create the AWS S3 client
            ECSS3Client s3 = ECSS3Factory.getS3Client();

            foreach (string key in KEY_LIST)
            {
                // create object request with retrieved input
                PutObjectRequest request = new PutObjectRequest()
                {
                    BucketName  = ECSS3Factory.S3_BUCKET,
                    ContentBody = key,
                    Key         = key
                };

                // create the object in demo bucket
                s3.PutObject(request);
            }


            while (true)
            {
                Console.Write("Enter the prefix (empty if none): ");
                string prefix = Console.ReadLine();
                Console.Write("Enter the delimiter (e.g. /, empty for none): ");
                string delimiter = Console.ReadLine();
                Console.Write("Enter the marker (empty if none): ");
                string marker = Console.ReadLine();
                Console.Write("Enter the max keys (empty for defaul): ");
                string maxKeys = Console.ReadLine();

                ListObjectsRequest request = new ListObjectsRequest()
                {
                    BucketName = ECSS3Factory.S3_BUCKET
                };

                if (prefix.Length > 0)
                {
                    request.Prefix = prefix;
                }

                if (delimiter.Length > 0)
                {
                    request.Delimiter = delimiter;
                }

                if (marker.Length > 0)
                {
                    request.Marker = marker;
                }

                if (maxKeys.Length > 0)
                {
                    request.MaxKeys = Int32.Parse(maxKeys);
                }

                ListObjectsResponse response = s3.ListObjects(request);

                Console.WriteLine("-----------------");
                Console.WriteLine("Bucket: " + ECSS3Factory.S3_BUCKET);
                Console.WriteLine("Prefix: " + response.Prefix);
                Console.WriteLine("Delimiter: " + response.Delimiter);
                Console.WriteLine("Marker: " + marker);
                Console.WriteLine("IsTruncated? " + response.IsTruncated);
                Console.WriteLine("NextMarker: " + response.NextMarker);

                Console.WriteLine();

                if (response.CommonPrefixes != null)
                {
                    foreach (string commonPrefix in response.CommonPrefixes)
                    {
                        Console.WriteLine("CommonPrefix: " + commonPrefix);
                    }
                }

                Console.WriteLine("Printing objects");
                Console.WriteLine("-----------------");


                foreach (S3Object s3Object in response.S3Objects)
                {
                    Console.WriteLine(String.Format("{0}    {1}     {2}", s3Object.LastModified.ToString(), s3Object.Size, s3Object.Key));
                }

                Console.Write("Another? (Y/N) ");
                string another = Console.ReadLine();

                if (another.ToUpper() == "N")
                {
                    break;
                }
            }

            foreach (string key in KEY_LIST)
            {
                s3.DeleteObject(ECSS3Factory.S3_BUCKET, key);
            }

            Console.ReadLine();
        }