eve-sqlalchemy icon indicating copy to clipboard operation
eve-sqlalchemy copied to clipboard

adding media type support

Open asif-mahmud opened this issue 7 years ago • 7 comments

as Eve documentation says it supports uploading media/files by media type. this commit is just following the example at http://python-eve.org/features.html#file-storage. One test is added for checking the validity of it.

asif-mahmud avatar Dec 16 '17 14:12 asif-mahmud

Thanks for your PR! As I never used the media feature with neither Eve nor Eve-SQLAlchemy: If I understand the docs and your posts in #161 correctly, this is not enough to actually make Eve-SQLAlchemy accept and store files, right?

Ideally we would have a working example or even integration test for this feature.

In any case we should update the docs too, as Eve docs just mention the use of GridFS, which I suppose is not the storage system of choice for Eve-SQLAlchemy users.

dkellner avatar Dec 20 '17 18:12 dkellner

Ya, thats true, we could provide a file system based storage. I have a working example of that. it takes in a few storage configurations like where to save files, if it serve them as url or base64 encoded string like the one option in GridFS example.

asif-mahmud avatar Dec 24 '17 13:12 asif-mahmud

Hi! Is there plan to merge this into master? I have implemented media in MongoDB with AWS S3 backend. So in reality there are only links saved into db. Having "type": "media" is handy as Eve automatically saves media link and takes care of "media" endpoint.

ernests avatar Feb 11 '21 08:02 ernests

fyi - forked, merged/implemented changes from this pr. With s3-storage plugin (https://github.com/gwainer/eve-s3storage/) implemented file storage on S3. It works.

p.s. there is a bug in eve-s3storage related to base64 encoding if RETURN_MEDIA_AS_BASE64_STRING is not set to False

ernests avatar Feb 11 '21 14:02 ernests

I'm open to merging this - but don't really have time at the moment to update the docs myself. IMO we should at least add an example on how to use this, as Eve's docs will not apply here (it mentions that GridFS is used by default).

If you could step in, rebase this on current master and add a short section on how to get this up and running, I think we're good to go! :-)

dkellner avatar Feb 15 '21 14:02 dkellner

I might try this. Haven't committed anything to public open-source project. Might need an assistance.

ernests avatar Feb 19 '21 06:02 ernests

No problem there - there's always a first! You can start by copying eve_sqlalchemy/examples/simple/ to something like eve_sqlalchemy/examples/media/ and getting a simple example to work. Preferrably not with S3 or any cloud service, but with the local filesystem to avoid depending on third parties.

Once you've got something, just create a PR (even if it's not ready yet), so I can give feedback.

dkellner avatar Feb 19 '21 07:02 dkellner