amazon web services - How do you create a directory structure using the ruby aws-sdk on s3? -


i trying upload entire directory s3 using ruby aws-sdk gem. first trying break down in smaller problems trying create 1 single folder , place file inside of folder. know technically s3 not have folders, objects. know can have directory-like structure though. can not find on how online , docs don't mention lot directory structure besides reading aws::s3::tree

this current attempt @ creating folder , adding file folder:

#created object called test obj = bucket.objects.create('test', 'data')  #this path css file uploading.  path_to_file = './directory/mobile/player.css'  #writing file test object obj.write(pathname.new(path_to_file)) 

what doing writing css file test. want create css file inside folder named test.

i sure misunderstanding way objects related directories. can spot going wrong or point me in correct direction?

you can use following code:

# instantiate s3 client aws credentials s3 = aws::s3.new(   :access_key_id => 'aws_access_key',   :secret_access_key => 'aws_secret_key' )  # if want create bucket # bucketname: name of bucket bucket = s3.buckets.create('bucketname', :acl => :public_read)  # push file s3 # bucketname: amazon bucket name  # key: file location want create file. # e.g, key = "user/appname/myapp.zip"   # file_to_save: location of file.   obj = bucket.objects['key'] obj.write(:file => file_name) puts obj.public_url  # key describes directory structure file 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -