• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Model.PutObjectRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Amazon.S3.Model.PutObjectRequest的典型用法代码示例。如果您正苦于以下问题:C# PutObjectRequest类的具体用法?C# PutObjectRequest怎么用?C# PutObjectRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PutObjectRequest类属于Amazon.S3.Model命名空间,在下文中一共展示了PutObjectRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UploadDataFileAsync

        public async Task UploadDataFileAsync(string data, string storageKeyId, string storageSecret, string region)
        {
            var regionIdentifier = RegionEndpoint.GetBySystemName(region);
            using (var client = new AmazonS3Client(storageKeyId, storageSecret, regionIdentifier))
            {
                try
                {
                    var putRequest1 = new PutObjectRequest
                    {
                        BucketName = AwsBucketName,
                        Key = AwsBucketFileName,
                        ContentBody = data,
                        ContentType = "application/json"
                    };

                    await client.PutObjectAsync(putRequest1);
                }
                catch (AmazonS3Exception amazonS3Exception)
                {
                    if (amazonS3Exception.ErrorCode != null &&
                        (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                    {
                        throw new SecurityException("Invalid Amazon S3 credentials - data was not uploaded.", amazonS3Exception);
                    }

                    throw new HttpRequestException("Unspecified error attempting to upload data: " + amazonS3Exception.Message, amazonS3Exception);
                }

                var response = await client.GetObjectAsync(AwsBucketName, AwsBucketFileName);
                using (var reader = new StreamReader(response.ResponseStream))
                {
                    Debug.WriteLine(await reader.ReadToEndAsync());
                }
            }
        }
开发者ID:Benrnz,项目名称:BudgetAnalyser,代码行数:35,代码来源:S3MobileDataUploader.cs


示例2: SendImageToS3

        public static Boolean SendImageToS3(String key, Stream imageStream)
        {
            var success = false;

            using (var client = new AmazonS3Client(RegionEndpoint.USWest2))
            {
                try
                {
                    PutObjectRequest request = new PutObjectRequest()
                    {
                        InputStream = imageStream,
                        BucketName = BucketName,
                        Key = key
                    };

                    client.PutObject(request);
                    success = true;
                }

                catch (Exception ex)
                {
                    // swallow everything for now.
                }
            }

            return success;
        }
开发者ID:raynjamin,项目名称:Sitecore-S3-Media,代码行数:27,代码来源:S3Client.cs


示例3: Enviar

        public void Enviar(bool compactar)
        {
            const string mime = "application/octet-stream";
            var nome = _arquivo.Substring(_arquivo.LastIndexOf('\\') + 1) + ".gz";
            var mem = new MemoryStream();

            using (var stream = File.OpenRead(_arquivo))
            using (var gz = new GZipStream(mem, CompressionMode.Compress, true))
            {
                stream.CopyTo(gz);
            }

            var len = mem.Length;
            var req = new PutObjectRequest()
                .WithContentType(mime)
                .WithBucketName(_bucketName)
                .WithKey(nome)
                .WithCannedACL(S3CannedACL.Private)
                .WithAutoCloseStream(true);

            req.InputStream = mem;
            _client.PutObject(req);

            _log.AppendFormat("Envio do arquivo {0} de {1} KB\n",
                              nome,
                              (len / 1024f));
        }
开发者ID:hesenger,项目名称:Backup,代码行数:27,代码来源:EnvioS3.cs


示例4: Write_File_To_S3

        public static bool Write_File_To_S3(String path, String key_name)
        {
            DateTime before = DateTime.Now;
            try
            {
                // simple object put
                PutObjectRequest request = new PutObjectRequest();
                request.WithFilePath(path)
                    .WithBucketName(bucketName)
                    .WithKey(key_name);

                S3Response response = s3_client.PutObject(request);
                response.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception n Write_File_To_S3(String path=" + path + ", String key_name=" + key_name + "). e.Message="+e.Message);
                Console.WriteLine("Write_File_To_S3(String path=" + path + ", String key_name=" + key_name + ") failed!!!");
                return false;
            }
            TimeSpan uploadTime = DateTime.Now - before;
            Console.WriteLine("Uploading " + path + " into S3 Bucket=" + bucketName + " , key=" + key_name + " took " + uploadTime.TotalMilliseconds.ToString() + " milliseconds");

            return true;
        }
开发者ID:tamirez3dco,项目名称:Rendering_Code,代码行数:25,代码来源:S3.cs


示例5: Main

        static void Main(string[] args)
        {
            using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client())
            {
                try
                {
                    NameValueCollection appConfig = ConfigurationManager.AppSettings;

                    // get file path
                    string folder = Path.GetFullPath(Environment.CurrentDirectory + "../../../../S3Uploader/");

                    // write uploader form to s3
                    const string uploaderTemplate = "uploader.html";
                    string file = Path.Combine(folder, "Templates/" + uploaderTemplate);

                    var request = new PutObjectRequest();
                    request.WithBucketName(appConfig["AWSBucket"])
                        .WithKey(appConfig["AWSUploaderPath"] + uploaderTemplate)
                        .WithInputStream(File.OpenRead(file));

                    request.CannedACL = S3CannedACL.PublicRead;
                    request.StorageClass = S3StorageClass.ReducedRedundancy;

                    S3Response response = client.PutObject(request);
                    response.Dispose();

                    // write js to s3
                    var jsFileNames = new[] { "jquery.fileupload.js", "jquery.iframe-transport.js", "s3_uploader.js" };
                    foreach (var jsFileName in jsFileNames)
                    {
                        file = Path.Combine(folder, "Scripts/s3_uploader/" + jsFileName);
                        request = new PutObjectRequest();

                        request.WithBucketName(appConfig["AWSBucket"])
                            .WithKey(appConfig["AWSUploaderPath"] + "js/" + jsFileName)
                            .WithInputStream(File.OpenRead(file));

                        request.CannedACL = S3CannedACL.PublicRead;
                        request.StorageClass = S3StorageClass.ReducedRedundancy;

                        response = client.PutObject(request);
                        response.Dispose();
                    }
                }
                catch (AmazonS3Exception amazonS3Exception)
                {
                    if (amazonS3Exception.ErrorCode != null &&
                        (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
                        amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                    {
                        Console.WriteLine("Please check the provided AWS Credentials.");
                        Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                    }
                    else
                    {
                        Console.WriteLine("An error occurred with the message '{0}' when writing an object", amazonS3Exception.Message);
                    }
                }
            }
        }
开发者ID:barneybbq,项目名称:S3Uploader,代码行数:60,代码来源:Program.cs


示例6: Execute

        public override void Execute()
        {
            int timeout = this._config.DefaultTimeout;
            if (this._fileTransporterRequest.Timeout != 0)
                timeout = this._fileTransporterRequest.Timeout;

            PutObjectRequest putRequest = new PutObjectRequest
            {
                BucketName = this._fileTransporterRequest.BucketName,
                Key = this._fileTransporterRequest.Key,
                CannedACL = this._fileTransporterRequest.CannedACL,
                ContentType = this._fileTransporterRequest.ContentType,
                FilePath = this._fileTransporterRequest.FilePath,
                Timeout = timeout,
                StorageClass = this._fileTransporterRequest.StorageClass,
                AutoCloseStream = this._fileTransporterRequest.AutoCloseStream,
                ServerSideEncryptionMethod = this._fileTransporterRequest.ServerSideEncryptionMethod,
            };
            putRequest.PutObjectProgressEvent += new EventHandler<PutObjectProgressArgs>(this.putObjectProgressEventCallback);

            putRequest.InputStream = this._fileTransporterRequest.InputStream;

            if (this._fileTransporterRequest.metadata != null && this._fileTransporterRequest.metadata.Count > 0)
                putRequest.WithMetaData(this._fileTransporterRequest.metadata);
            if (this._fileTransporterRequest.Headers != null && this._fileTransporterRequest.Headers.Count > 0)
                putRequest.AddHeaders(this._fileTransporterRequest.Headers);

            this._s3Client.PutObject(putRequest);
        }
开发者ID:pbutlerm,项目名称:dataservices-sdk-dotnet,代码行数:29,代码来源:SimpleUploadCommand.cs


示例7: PutImage

        public string PutImage(IWebCamImage webCamImage, out string key)
        {
            if (webCamImage.Data != null) // accept the file
            {
                // AWS credentials.
                const string accessKey = "{sensitive}";
                const string secretKey = "{sensitive}";

                // Setup the filename.
                string fileName = Guid.NewGuid() + ".jpg";
                string url = null;

                // Drop the image.
                AmazonS3 client;
                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey))
                {
                    var request = new PutObjectRequest();
                    var config = ConfigurationManager.AppSettings;
                    request.WithBucketName(config["awsBucket"])
                        .WithCannedACL(S3CannedACL.PublicRead)
                        .WithKey(fileName).WithInputStream(new MemoryStream(webCamImage.Data));
                    S3Response response = client.PutObject(request);
                    url = config["awsRootUrl"] + "/" + config["awsBucket"] + "/" + fileName;
                }

                // Return our result.
                key = fileName;
                return url;
            }
            key = null;
            return null;
        }
开发者ID:bernardoleary,项目名称:MyBigBro,代码行数:32,代码来源:AwsStorageServiceAgent.cs


示例8: UploadFile

        private bool UploadFile(string filePath, string s3directory)
        {
            //clean up s3 directory
            s3directory = s3directory.Replace('\\', '/');
            if (s3directory.StartsWith("/")) s3directory = s3directory.Substring(1);
            if (Config.LowerCaseEnforce) s3directory = s3directory.ToLower();

            var key = string.Format("{0}{1}{2}", s3directory, (string.IsNullOrEmpty(s3directory) ? null : "/"), Path.GetFileName(filePath));

            PutObjectRequest request = new PutObjectRequest()
            {
                BucketName = _bucketName,
                Key = key,
                FilePath = filePath,
            };

            PutObjectResponse response = this._client.PutObject(request);

            bool success = (response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            if (success)
                Logger.log.Info("Successfully uploaded file " + filePath + " to " + key);
            else
                Logger.log.Info("Failed to upload file " + filePath);
            return success;
        }
开发者ID:mmendelson222,项目名称:s3-tool,代码行数:25,代码来源:S3Client.cs


示例9: CalculateDiffClocks

        public TimeSpan CalculateDiffClocks()
        {
            try {
                SQ.Repository.File clockFile = new RemoteFile (Constant.CLOCK_TIME);
                PutObjectRequest putObject = new PutObjectRequest ()
                {
                    BucketName = bucketName,
                    Key = clockFile.Name,
                    ContentBody = string.Empty
                };

                DateTime localClock;
                using (S3Response response = Connect ().PutObject (putObject)){
                    localClock = DateTime.Now;
                    response.Dispose ();
                }

                ListObjectsResponse files = Connect ().ListObjects (new ListObjectsRequest ().WithBucketName (bucketName));
                S3Object remotefile = files.S3Objects.Where (o => o.Key == clockFile.Name).FirstOrDefault();
                string sRemoteclock = remotefile.LastModified;

                Delete(clockFile);

                DateTime remoteClock = Convert.ToDateTime (sRemoteclock);

                return localClock.Subtract(remoteClock);

            } catch(Exception e) {
                return new TimeSpan(0);
                Logger.LogInfo ("Connection","Fail to determinate a remote clock: "+e.Message +" \n");
            }
        }
开发者ID:adaptive,项目名称:qloudsync,代码行数:32,代码来源:ConnectionManager.cs


示例10: UploadFile

        public ActionResult UploadFile()
        {
            var file = Request.Files[0];

            if (file != null && file.ContentLength > 0)
            {
                var account = _readOnlyRepository.First<Account>(x => x.Email == User.Identity.Name);

                var client = AWSClientFactory.CreateAmazonS3Client();
                var putObjectRequest = new PutObjectRequest
                    {
                        BucketName = account.BucketName,
                        Key = file.FileName,
                        InputStream = file.InputStream
                    };

                client.PutObject(putObjectRequest);
                //save to database here

                Success("The file " + file.FileName + " was uploaded.");
                return RedirectToAction("Index");
            }
            Error("There was a problem uploading the file.");
            return View("Upload");
        }
开发者ID:kmiloaguilar,项目名称:progra4-minidropbox,代码行数:25,代码来源:DiskController.cs


示例11: ConstructRequest

        private PutObjectRequest ConstructRequest()
        {
            PutObjectRequest putRequest = new PutObjectRequest()
            {
                BucketName = this._fileTransporterRequest.BucketName,
                Key = this._fileTransporterRequest.Key,
                CannedACL = this._fileTransporterRequest.CannedACL,
                ContentType = this._fileTransporterRequest.ContentType,
                StorageClass = this._fileTransporterRequest.StorageClass,
                AutoCloseStream = this._fileTransporterRequest.AutoCloseStream,
                AutoResetStreamPosition = this._fileTransporterRequest.AutoResetStreamPosition,
                ServerSideEncryptionMethod = this._fileTransporterRequest.ServerSideEncryptionMethod,
                Headers = this._fileTransporterRequest.Headers,
                Metadata = this._fileTransporterRequest.Metadata,
#if (BCL && !BCL45)
                Timeout = ClientConfig.GetTimeoutValue(this._config.DefaultTimeout, this._fileTransporterRequest.Timeout)
#endif
            };

#if BCL
            putRequest.FilePath = this._fileTransporterRequest.FilePath;
#elif WIN_RT || WINDOWS_PHONE
            if (this._fileTransporterRequest.IsSetStorageFile())
            {
                putRequest.StorageFile = this._fileTransporterRequest.StorageFile;
            }
#endif
            var progressHandler = new ProgressHandler(this.PutObjectProgressEventCallback);
            putRequest.StreamUploadProgressCallback += progressHandler.OnTransferProgress;

            putRequest.InputStream = this._fileTransporterRequest.InputStream;
            return putRequest;
        }
开发者ID:virajs,项目名称:aws-sdk-net,代码行数:33,代码来源:SimpleUploadCommand.cs


示例12: SaveImage

 /// <summary>
 /// Saves image to images.climbfind.com
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="filePath"></param>
 /// <param name="key"></param>
 public override void SaveImage(Stream stream, string filePath, string key)
 {
     try
     {
         using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(Stgs.AWSAccessKey, Stgs.AWSSecretKey, S3Config))
         {
             // simple object put
             PutObjectRequest request = new PutObjectRequest();
             request.WithBucketName("images.climbfind.com" + filePath);
             request.WithInputStream(stream);
             request.ContentType = "image/jpeg";
             request.Key = key;
             request.WithCannedACL(S3CannedACL.PublicRead);
             client.PutObject(request);
         }
     }
     catch (AmazonS3Exception amazonS3Exception)
     {
         if (amazonS3Exception.ErrorCode != null &&
             (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
             amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
         {
             Console.WriteLine("Please check the provided AWS Credentials.");
             Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
         }
         else
         {
             Console.WriteLine("An error occurred with the message '{0}' when writing an object", amazonS3Exception.Message);
         }
     }
 }
开发者ID:jkresner,项目名称:Climbfind_v4_2011,代码行数:37,代码来源:AwsS3ImagePersister.cs


示例13: CreateFileFromStream

        public static bool CreateFileFromStream(Stream InputStream, string FileName, string _bucketName = "doc2xml")
        {
            bool _saved=false;
            try
            {

                IAmazonS3 client;
                AmazonS3Config objCon = new AmazonS3Config() ;
                objCon.RegionEndpoint = RegionEndpoint.USEast1;
                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(_awsAccessKey, _awsSecretKey,objCon))
                {
                    var request = new PutObjectRequest()
                    {
                        BucketName = _bucketName,
                        CannedACL = S3CannedACL.PublicRead,//PERMISSION TO FILE PUBLIC ACCESIBLE
                        Key = string.Format("{0}", FileName),
                        InputStream = InputStream//SEND THE FILE STREAM
                    };

                    client.PutObject(request);
                    _saved = true;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();

            }
            return _saved;
        }
开发者ID:LawrenceAntony,项目名称:Docx2XML,代码行数:30,代码来源:AWSS3.cs


示例14: BucketRegionTestRunner

        public BucketRegionTestRunner(bool useSigV4, bool useSigV4SetExplicitly = false)
        {
            originalUseSignatureVersion4 = AWSConfigsS3.UseSignatureVersion4;
            originalUseSigV4SetExplicitly = GetAWSConfigsS3InternalProperty();
            AWSConfigsS3.UseSignatureVersion4 = useSigV4;
            SetAWSConfigsS3InternalProperty(useSigV4SetExplicitly);

            CreateAndCheckTestBucket();
            if (TestBucketIsReady)
            {
                GetObjectMetadataRequest = new GetObjectMetadataRequest()
                {
                    BucketName = TestBucket.BucketName,
                    Key = TestObjectKey
                };
                PutObjectRequest = new PutObjectRequest()
                {
                    BucketName = TestBucket.BucketName,
                    Key = TestObjectKey,
                    ContentBody = TestContent
                };
                PreSignedUrlRequest = new GetPreSignedUrlRequest
                {
                    BucketName = BucketName,
                    Key = BucketRegionTestRunner.TestObjectKey,
                    Expires = DateTime.Now.AddHours(1)
                };
            }
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:29,代码来源:BucketRegionTestRunner.cs


示例15: Execute

        public override void Execute()
        {


            PutObjectRequest putRequest = new PutObjectRequest()
            {
                BucketName = this._fileTransporterRequest.BucketName,
                Key = this._fileTransporterRequest.Key,
                CannedACL = this._fileTransporterRequest.CannedACL,
                ContentType = this._fileTransporterRequest.ContentType,
                FilePath = this._fileTransporterRequest.FilePath,
                StorageClass = this._fileTransporterRequest.StorageClass,
                AutoCloseStream = this._fileTransporterRequest.AutoCloseStream,
                AutoResetStreamPosition = this._fileTransporterRequest.AutoResetStreamPosition,
                ServerSideEncryptionMethod = this._fileTransporterRequest.ServerSideEncryptionMethod,
                Headers = this._fileTransporterRequest.Headers,
                Metadata = this._fileTransporterRequest.Metadata,
#if (BCL && !BCL45)
                Timeout = ClientConfig.GetTimeoutValue(this._config.DefaultTimeout, this._fileTransporterRequest.Timeout)
#endif
            };
            putRequest.StreamUploadProgressCallback += new EventHandler<Runtime.StreamTransferProgressArgs>(this.putObjectProgressEventCallback);

            putRequest.InputStream = this._fileTransporterRequest.InputStream;

            this._s3Client.PutObject(putRequest);
        }
开发者ID:scopely,项目名称:aws-sdk-net,代码行数:27,代码来源:SimpleUploadCommand.cs


示例16: SaveObjectInAws

        static void SaveObjectInAws(Stream pObject, string keyname)
        {
            try
            {
                using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client())
                {
                    // simple object put
                    PutObjectRequest request = new PutObjectRequest();
                    request.WithBucketName(ConfigurationManager.AppSettings["bucketname"]).WithKey(keyname).WithInputStream(pObject);

                    using (client.PutObject(request)) { }
                }
            }
            catch (AmazonS3Exception amazonS3Exception)
            {
                if (amazonS3Exception.ErrorCode != null &&
                    (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
                    amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                {
                    Console.WriteLine("Please check the provided AWS Credentials.");
                    Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                    throw;
                }

                Console.WriteLine("An error occurred with the message '{0}' when writing an object", amazonS3Exception.Message);
                throw;
            }
        }
开发者ID:lazarofl,项目名称:MVC3-Plupload-To-Amazon-S3,代码行数:28,代码来源:HomeController.cs


示例17: UploadFileButton_Click

    protected void UploadFileButton_Click(object sender, EventArgs e)
    {
        string filePath = Server.MapPath(VideoUploader.PostedFile.FileName);
        string existingBucketName = "ccdem";
        string keyName = Membership.GetUser().ProviderUserKey.GetHashCode().ToString();
        string fileName = UtilityFunctions.GenerateChar() + VideoUploader.PostedFile.FileName;
        IAmazonS3 client;
        using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(System.Web.Configuration.WebConfigurationManager.AppSettings[0].ToString(), System.Web.Configuration.WebConfigurationManager.AppSettings[1].ToString()))
        {

            var stream = VideoUploader.FileContent;

            stream.Position = 0;

            PutObjectRequest request = new PutObjectRequest();
            request.InputStream = stream;
            request.BucketName = existingBucketName;
            request.CannedACL = S3CannedACL.PublicRead;
            request.Key = keyName + "/" + fileName;
            PutObjectResponse response = client.PutObject(request);
        }

        string bucketUrl = "https://s3-us-west-2.amazonaws.com/" + existingBucketName + "/" + keyName + "/" + fileName;
        cloudFrontUrl = cloudFrontUrl + keyName + "/" + fileName;
        TranscoderUtility.Transcode(keyName + "/" + fileName, keyName + "/mob_" + fileName, existingBucketName);
           // lblPath.Text = "<br/>Successfully uploaded into S3:" + bucketUrl + "<br/> Cloudfront distribution url is " + cloudFrontUrl;
        Models.Video video = new Models.Video() { Url = cloudFrontUrl };
        int newVid = DAL.DataAccessLayer.AddVideo(video, (Guid)Membership.GetUser().ProviderUserKey);
        string vid=Request.QueryString["vid"].ToString();
        if(!vid.Equals(""))
            DAL.DataAccessLayer.AddResponseVideo(vid,newVid.ToString());
        RefreshPage();
    }
开发者ID:Walliee,项目名称:vTweet-2,代码行数:33,代码来源:Reply.aspx.cs


示例18: Write

        public void Write(string key, Stream stream)
        {
            try
            {
                using (var s3 = AWSClientFactory.CreateAmazonS3Client(Settings.AccessKey, Settings.SecretAccessKey, RegionEndpoint.EUWest1))
                {
                    stream.Position = 0;

                    var request = new PutObjectRequest
                        {
                            BucketName = Settings.UploadBucket,
                            CannedACL = S3CannedACL.PublicRead,
                            InputStream = stream,
                            AutoCloseStream = true,
                            ContentType = "application/octet-stream",
                            Key = key
                        };

                    s3.PutObject(request);
                }
            }
            catch (AmazonS3Exception e)
            {
                throw new UnhandledException("Upload failed", e);
            }
        }
开发者ID:CHAOS-Community,项目名称:Portal.Module.Larmfm,代码行数:26,代码来源:S3.cs


示例19: Put

        public string Put(string key, Stream inputStream)
        {
            VerifyKey(key);

            key = ConvertKey(key);

            // Setting stream position is not necessary for AWS API 
            // but we are bing explicit to demostrate that the position does matter depending on the underlying API.
            // For example, GridFs API does require position to be at zero!

            inputStream.Position = 0;

            var request = new PutObjectRequest
            {
                BucketName = BucketName,
                InputStream = inputStream,
                Key = key,
                CannedACL = S3CannedACL.PublicRead,
                AutoCloseStream = false,
            };

            var response = S3.PutObject(request);

            inputStream.Position = 0; // Rewind the stream as the stream could be used again after the method returns.

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                return BucketUrl + key;
            }


            return string.Empty;
        }
开发者ID:eHanlin,项目名称:Hanlin.Common,代码行数:33,代码来源:S3CompatibleService.cs


示例20: Execute

        public override void Execute()
        {
            int timeout = this._config.DefaultTimeout;
            if (this._fileTransporterRequest.Timeout != 0)
                timeout = this._fileTransporterRequest.Timeout;

            PutObjectRequest putRequest = new PutObjectRequest()
                .WithBucketName(this._fileTransporterRequest.BucketName)
                .WithKey(this._fileTransporterRequest.Key)
                .WithCannedACL(this._fileTransporterRequest.CannedACL)
                .WithContentType(this._fileTransporterRequest.ContentType)
                .WithFilePath(this._fileTransporterRequest.FilePath)
                .WithTimeout(timeout)
                .WithStorageClass(this._fileTransporterRequest.StorageClass)
                .WithAutoCloseStream(this._fileTransporterRequest.AutoCloseStream)
                .WithSubscriber(new EventHandler<PutObjectProgressArgs>(this.putObjectProgressEventCallback));

            putRequest.InputStream = this._fileTransporterRequest.InputStream;

            if (this._fileTransporterRequest.metadata != null && this._fileTransporterRequest.metadata.Count > 0)
                putRequest.WithMetaData(this._fileTransporterRequest.metadata);
            if (this._fileTransporterRequest.Headers != null && this._fileTransporterRequest.Headers.Count > 0)
                putRequest.AddHeaders(this._fileTransporterRequest.Headers);

            this._s3Client.PutObject(putRequest);
        }
开发者ID:friism,项目名称:AWS-SDK-for-.NET,代码行数:26,代码来源:SimpleUploadCommand.cs



注:本文中的Amazon.S3.Model.PutObjectRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.RestoreObjectRequest类代码示例发布时间:2022-05-24
下一篇:
C# Model.ListObjectsRequest类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap