Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save paingsoethaw/ceb18694cdca87c50c29 to your computer and use it in GitHub Desktop.
Save paingsoethaw/ceb18694cdca87c50c29 to your computer and use it in GitHub Desktop.
file = "public/to_be_uploaded.txt"
file_path = Rails.root.join(file)
local_file = File.open(local_file_path)
bucket_name = "BUCKET_NAME"
s3 = AWS::S3.new(
:access_key_id => "KEY",
:secret_access_key => "SECRET_ACCESS_KEY",
:s3_endpoint => "S3_ENDPOINT"
)
## Define upload file name ##
key = File.basename("uploaded_on_s3.txt")
s3.buckets[bucket_name].objects[key].write(:file => local_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment