Comments (6)
from django-s3-storage.
Is there a way to get it if I'm not using the s3 storage as the default? I'm actually only using it for a handful of models that allow upload of user content. I have like storage=s3storage
on individual file fields in the model. Thank you!
from django-s3-storage.
Answered my own question: the s3_connection
is available from the specified s3storage connection as well:
conn = s3storage.s3_connection
I'll add another comment with the working code and then close the ticket once I have it. Thank you!
from django-s3-storage.
It turns out the ETag is not a reliable source for a file hash. It changes not only depending on the content of the file, but also on how it was uploaded and what type of encryption was used. https://docs.aws.amazon.com/AmazonS3/latest/API/API_Object.html
I'm back to looking for a way to intercept the file before it's uploaded to s3. Does it ever reside on disk anywhere? In a temp directory or something?
Here's the working code I have to save the ETag, but it doesn't really solve the problem.
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if(self.file):
self.file_size = self.file.file.size
conn = s3storage.s3_connection
details = conn.head_object(
Bucket=s3bucket,
Key=str(self.file.file),
)
self.file_hash = details.get("ETag").replace('"', '')
super().save()
from django-s3-storage.
from django-s3-storage.
from django-s3-storage.
Related Issues (20)
- Allow the storage to work in a Docker environment HOT 4
- How to delete record which used django-s3-storge HOT 3
- I am defined AWS_S3_ENDPOINT_URL in settings but still use default S3 endpoint url HOT 2
- if I am using rotated s3 credentials how do I setup credentials HOT 2
- Is there a way to get upload progress? HOT 4
- support for large file upload HOT 2
- Setting similar to `AWS_S3_KEY_PREFIX` but instead prepend a dynamic param for each model's files HOT 2
- Caching with pre-signed url HOT 7
- Public-read buckets and AWS_S3_BUCKET_AUTH HOT 4
- File is closed after s3 upload HOT 9
- Incompatibility issues with Django>=4.0 HOT 1
- Issue when upgrading to version 0.13.5 or higher HOT 4
- Huge Thanks HOT 2
- Update settings to define multiple S3 buckets HOT 1
- Document the `AWS_S3_MAX_POOL_CONNECTIONS` setting HOT 1
- Issues configuring AWS_S3_ENDPOINT_URL HOT 2
- Use Django's system check framework instead of log message HOT 1
- s3 bucket names being stored directly in migrations HOT 5
- Cannot open files in plain text mode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-s3-storage.