AWS Code Sample


create_bucket.rb allows anyone with the presigned URL can upload an object by using the AWS SDK for Ruby.

#** #* Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. #* #* This file is licensed under the Apache License, Version 2.0 (the "License"). #* You may not use this file except in compliance with the License. A copy of #* the License is located at #* #* #* #* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR #* CONDITIONS OF ANY KIND, either express or implied. See the License for the #* specific language governing permissions and limitations under the License. #** #Uploading an object using a presigned URL for SDK for Ruby - Version 3. require 'aws-sdk-s3' require 'net/http' s3 ='us-west-2') obj = s3.bucket('BucketName').object('KeyName') # Replace BucketName with the name of your bucket. # Replace KeyName with the name of the object you are creating or replacing. url = URI.parse(obj.presigned_url(:put)) body = "Hello World!" # This is the contents of your object. In this case, it's a simple string. Net::HTTP.start( do |http| http.send_request("PUT", url.request_uri, body, { # This is required, or Net::HTTP will add a default unsigned content-type. "content-type" => "", }) end puts # This will print out the contents of your object to the terminal window.

Sample Details

Service: s3

Last tested: 2019-02-11

Author: AWS

Type: snippet

On this page: