I know we now can upload/post a media type field to the python-eve REST-API framework
and it will be stored in mongodb
. Is there a way we can change the storage of those media?
E.g. a remote storage server e.g. amazon S3
? So that we only store the URL of the image in mongodb instead of the whole image?
While the standard behaviour is to store on GridFS, you can also provide your own MediaStorage
subclass which can store wherever you want to (file system, S3, etc.)
Something like this would do the trick:
from eve.io.media import MediaStorage
class AmazonS3MediaStorage(MediaStorage):
""" Your actual implementation """
pass
app = Eve(media=AmazonS3MediaStorage)
if __name__ == '__main__':
app.run()
Check out the actual MediaStorage
class for implementation details and/or see the actual GridFSMediaStorage class for reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With