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

Error empty: botocore.exceptions.ClientError: An error occurred () when calling the PutObject operation: #954

Closed
soleyj opened this issue Nov 12, 2020 · 3 comments

Comments

@soleyj
Copy link

soleyj commented Nov 12, 2020

Hello,

I have configured the storage to upload the static file into a digital ocean storage( comaptible with S3).

When I run collectstatic I am able to upload some files, because it appears in the server, and I am able to consume those files. But in the middle of the command collectstatic it breaks and return this error:

botocore.exceptions.ClientError: An error occurred () when calling the PutObject operation:

The error is empty :(

Also, I have created a simple python script with 'os' and 'boto3' to upload my static folder "manually" and all the files were uploaded correctly.

So I think that the error should be in the here, in the library.

I will attach the setting.py and the other code.

`AWS_ACCESS_KEY_ID = 'xxx'
AWS_SECRET_ACCESS_KEY = 'xxx'

AWS_STORAGE_BUCKET_NAME = 'xxx'
AWS_S3_ENDPOINT_URL = 'https://fra1.digitaloceanspaces.com'
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static_django'
AWS_DEFAULT_ACL = None

STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

STATIC_URL = '{}/{}/'.format(AWS_S3_ENDPOINT_URL, AWS_LOCATION)
STATIC_ROOT = 'static/'

STATICFILES_DIRS = [
STATIC_DIR,
]`

Python script manual upload:

`import os
import boto3

path = 'assets'

files = []

r=root, d=directories, f = files

for r, d, f in os.walk(path):
for file in f:
files.append(os.path.join(r, file))

for f in files:
print(f)

session = boto3.session.Session()
client = session.client('s3',
region_name='fra1',
endpoint_url='https://fra1.digitaloceanspaces.com',
aws_access_key_id=('xx'),
aws_secret_access_key=('xxx'))

print(client)

response = client.list_buckets()
for space in response['Buckets']:
print(space['Name'])
for f in files:
print(f)
client.upload_file(f, "xxx", f,ExtraArgs={'ACL': 'public-read'})`

Thanks in advice

@jschneier
Copy link
Owner

#968 contains a storage specifically for handling staticfiles, can you try that out?

@fozdemir40
Copy link

fozdemir40 commented Jan 27, 2021

Hi, I am facing the similiar issue with an empty error. How did you manage to fix this?

@soleyj
Copy link
Author

soleyj commented Jan 27, 2021

@fozdemir40 my error was that digital ocean don't accept a large amount of upload per second. AndI imagine that collectstatic upload faster than digital ocean. I tried S3 from amazon and my problem was solved.

Also, I didn't check the #968, because I was just realize that comment.

I don't know if your problem is at DO, maybe could be the same thing.

Good luck!

@jschneier jschneier closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants