Skip to content
Snippets Groups Projects
Commit 218b18b4 authored by des20's avatar des20
Browse files

begin understending

parent 4012bfc7
No related branches found
No related tags found
No related merge requests found
Pipeline #35154 failed
require 'aws-sdk-s3'
require "json"
Aws.config.update(
endpoint: 'https://s3.c3sl.ufpr.br',
access_key_id:'GMHK60049J0FT1ZC5EPT',
access_key_id: ' GMHK6OO49J0FT1ZC5EPT',
secret_access_key: 'MyknbDcne4JRNCi6GJhDsSaH3No4TpdCzIjwcJ0K',
force_path_style: true,
region: 'default'
region: 'default',
)
bucket_name = "portalmecs3"
s3_client = Aws::S3::Client.new
buckets = s3_client.list_buckets
file = open("/home/des20/hello.txt")
file_data = file.read
s3_client.put_object(
key: 'hello.txt',
body: file_data,
bucket: bucket_name,
content_type: 'text/plain'
)
object=s3_client.get_object(
key: 'hello.txt',
bucket: 'portalmecs3',
)
puts object.body.read
# wrapper = Aws::S3::Object.new(bucket_name, 'hello.txt')
# obj_data = wrapper.getObjectContent
# puts obj_data
# s3_client.delete_object(
# key: 'hello.txt',
# bucket: 'portalmecs3',
# )
# buckets = s3_client.list_buckets
puts 'List of S3 buckets:'
buckets.each do |bucket|
puts bucket.name
end
\ No newline at end of file
# puts 'List of S3 buckets:'
# buckets.each do |bucket|
# puts {bucket.name}\t{bucket.creation_date}
# end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment