Hi is it possible to add a http header to a pdf file like Content-Disposition:attachment;filename=test.pdf in python, for 开发者_开发技巧now what i do is i send my pdf files to Amazons S3 by adding
--add-header=Content-Disposition:attachment;filename=test.pdf
but i would like to set this in python
Do you mean you want to upload files to S3 using Python and set some extra headers along the way?
If so, you could use simples3 library. Or some other similar library. I'll cover using simples3
:
Follow the docs on how to instantiate a S3Bucket
object. Once you have that, you can do:
bucket.put('path/to/your/pdf/object/on/s3',
pdf_object_bytes,
headers={'Content-Disposition': 'attachment;filename=test.pdf'})
Tried writing to a file or parsing everything as a string?
精彩评论