Amazon S3: how to set requests to use virtual host in ruby aws sdk -


currently, sending requests s3 using aws-sdk ruby follow:

#!/usr/bin/ruby # require 'aws-sdk' s3 = aws::s3::resource.new(region: 'test',     endpoint:'http://10.0.23.45:8081') my_bucket = s3.bucket('test.bucket-name') my_bucket.objects.limit(50).each |obj|    puts "  #{obj.key} => #{obj.etag}" end 

but request trying hit url endpoint(virtual hosting):

http://test.bucket-name.10.0.23.45:8081 

i use path style addressing instead. want request url endpoint like:

http://10.0.23.45:8081/test.bucket-name/ 

any idea how set path style addressing instead of virtual hosting address? thanks.

you need set option :virtual_host true according documentation.

so in case should work:

s3.bucket('10.0.23.45:8081').object('test.bucket-name').public_url(virtual_host: true) #=> "http://10.0.23.45:8081/test.bucket-name/" 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -