Exemplo n.º 1
0
        /// <summary>
        /// Uploads the file.
        /// </summary>
        /// <returns>null</returns>
        /// <param name="tokenResponse">Token response.</param>
        /// <param name="uploadAuthResponse">Upload auth response.</param>
        public void UploadFile(TokenResponse tokenResponse, UploadAuthResponse uploadAuthResponse)
        {
            var tr       = new TokenRequest();
            var FileName = "gofishing.txt";
            var PathName = Environment.CurrentDirectory + "/../../";

            try
            {
                AmazonS3Config config = new AmazonS3Config
                {
                    RegionEndpoint = Amazon.RegionEndpoint.APSoutheast2,
                    UseHttp        = false
                };
                var s3Client = new AmazonS3Client(
                    uploadAuthResponse.credentials.AccessKeyId,
                    uploadAuthResponse.credentials.SecretAccessKey,
                    uploadAuthResponse.credentials.SessionToken,
                    config
                    );
                var transferUtility = new TransferUtility(s3Client);
                var request         = new TransferUtilityUploadRequest
                {
                    BucketName = uploadAuthResponse.BucketName,
                    Key        = uploadAuthResponse.KeyPrefix + FileName,
                    FilePath   = PathName + FileName
                };

                transferUtility.Upload(request);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
        public void Entrance_04_GetUploadAuth()
        {
            uploadAuthResponse = _entrance.UploadAuth(tokenResponse) as UploadAuthResponse;

            Assert.AreEqual(1, 1);
        }