Exemplo n.º 1
0
        public async Task S3DownloadFile()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket1/testfile1.txt");
            s3WebRequest.Method = "GET";

            long i = 0;

            System.Net.S3.S3WebResponse s3WebResponse = (System.Net.S3.S3WebResponse) await s3WebRequest.GetResponseAsync();

            Assert.Equal(200, s3WebResponse.StatusCode);
            Assert.Equal("application/octet-stream", s3WebResponse.ContentType);
            Assert.Equal(128 * 1024 * 1024, s3WebResponse.ContentLength);

            using (Stream s3WebResponseStream = s3WebResponse.GetResponseStream())
            {
                int j = 0;
                do
                {
                    j  = s3WebResponseStream.Read(new byte[1024], 0, 1024);
                    i += j;
                }while (j > 0);
            }

            Assert.Equal(128 * 1024 * 1024, i);
        }
Exemplo n.º 2
0
        public async Task S3DeleteFile()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket1/testfile1.txt");
            s3WebRequest.Method = "RM";

            System.Net.S3.S3WebResponse s3WebResponse = (System.Net.S3.S3WebResponse) await s3WebRequest.GetResponseAsync();

            Assert.Equal(204, s3WebResponse.StatusCode);
        }
        public async Task S3DeleteBucket()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket");
            s3WebRequest.Method = "RMB";
            Assert.Equal("bucket", s3WebRequest.BucketName);
            System.Net.S3.S3ObjectWebResponse <DeleteBucketResponse> s3WebResponse =
                (System.Net.S3.S3ObjectWebResponse <DeleteBucketResponse>)(await s3WebRequest.GetResponseAsync());

            Assert.Equal(204, s3WebResponse.StatusCode);
        }
        public void S3ListBuckets()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket");
            s3WebRequest.Method = "LSB";
            System.Net.S3.S3ObjectWebResponse <ListBucketsResponse> s3WebResponse = (System.Net.S3.S3ObjectWebResponse <ListBucketsResponse>)s3WebRequest.GetResponse();

            Assert.Equal(200, s3WebResponse.StatusCode);

            Assert.Equal(0, s3WebResponse.GetObject().Buckets.Count);
        }
Exemplo n.º 5
0
        public async Task S3ListUploadedFile()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket1/");
            s3WebRequest.Method = "LS";

            System.Net.S3.S3ObjectWebResponse <ListObjectsResponse> s3WebResponse =
                (System.Net.S3.S3ObjectWebResponse <ListObjectsResponse>) await s3WebRequest.GetResponseAsync();

            Assert.Equal(200, s3WebResponse.StatusCode);

            Assert.Equal(1, s3WebResponse.GetObject().S3Objects.Count);
            Assert.Equal(128 * 1024 * 1024, s3WebResponse.GetObject().S3Objects.First().Size);
        }
Exemplo n.º 6
0
        public async Task S3UploadFile()
        {
            System.Net.S3.S3WebRequest s3WebRequest = (System.Net.S3.S3WebRequest)WebRequest.Create("s3://bucket1/testfile1.txt");
            s3WebRequest.Method        = "POST";
            s3WebRequest.ContentLength = 128 * 1024 * 1024;

            Stream uploadStream = await s3WebRequest.GetRequestStreamAsync();

            Helpers.RunContentStreamGenerator(128 * 1024, uploadStream);
            System.Net.S3.S3WebResponse s3WebResponse = (System.Net.S3.S3WebResponse) await s3WebRequest.GetResponseAsync();

            Assert.Equal(200, s3WebResponse.StatusCode);
        }