[IMP] attachment_s3: Consider bin_size context key

When bin_size context key is set, read operations on attachments
are supposed to return the size of the attachment and not its content
This commit is contained in:
Akim Juillerat
2020-03-18 12:51:48 +01:00
parent 20a8493a63
commit bd3be08203
+2
View File
@@ -122,6 +122,8 @@ class IrAttachment(models.Model):
bucket.meta.client.head_object( bucket.meta.client.head_object(
Bucket=bucket.name, Key=key Bucket=bucket.name, Key=key
) )
if bin_size:
return bucket.Object(key).content_length
res = io.BytesIO() res = io.BytesIO()
bucket.download_fileobj(key, res) bucket.download_fileobj(key, res)
res.seek(0) res.seek(0)