Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 Drivers issue. #1379

Closed
570096 opened this issue Dec 11, 2019 · 2 comments
Closed

S3 Drivers issue. #1379

570096 opened this issue Dec 11, 2019 · 2 comments

Comments

@570096
Copy link

570096 commented Dec 11, 2019

## Summary
Uploading a file into S3 . I am getting below error.

ERROR:
**<LibcloudError in <class 'libcloud.storage.drivers.s3.S3StorageDriver'> 'This bucket is located in a different region. Please use the correct driver.'>**

## Detailed Information
Version of libcloud: 2.6.1
Python version: 3.7
code:

`import libcloud
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
FILE_PATH = 'filepath' 
cls = get_driver(Provider.S3)
driver = cls('api key','api secret key')
container = driver.get_container(container_name='my-backups-12345')
extra = {'content_type': 'application/octet-stream'}
with open(FILE_PATH, 'rb') as iterator:
                obj = driver.upload_object_via_stream(iterator=iterator,
                                                      container=container,
                                                      object_name='images_backup.tar',
                                                      extra=extra)

In the above code i mentioned correct driver then also am getting below error.please help me on this issue.Am I missing something?

image

@Kami
Copy link
Member

Kami commented Dec 21, 2019

@570096 I suggest you to install the latest stable version of Libcloud (v2.7.0) and then pass region=<region name> argument to the driver constructor and make sure the region matches the region where the bucket is located.

In v2.7.0, that exception has also been improved so the error now also includes the name of the region where the bucket in question is located.

For example, if your driver is located in the us-west-2 region, you would instantiate a driver like this:

cls = get_driver(Provider.S3)
driver = cls('api key','api secret key', region='us-west-2')

If you are working with buckets in different regions, you need to use multiple driver instances (one per region).

@Kami Kami closed this as completed Jan 10, 2020
@JexPY
Copy link

JexPY commented Aug 21, 2020

@Kami If this answer will be in documentation there will be no questions. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants