문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top