SQLFORM uploads with uploadfs and Amazon S3

129 views
Skip to first unread message

Mark Graves

unread,
Oct 3, 2014, 5:31:28 PM10/3/14
to web...@googlegroups.com
Hey Everyone,

Does anyone have experience using SQLFORM with Amazon S3 for upload fields?

My standard SQLFORM(db.table,record) is not removing the S3 object for the uploaded file.  It is properly uploading the file and getting the obfuscated filename. 

Is there another argument I'm missing or do I have to implement that myself?

I can post a basic example if need be.

Thanks,

Mark

Massimo Di Pierro

unread,
Oct 6, 2014, 10:21:48 PM10/6/14
to web...@googlegroups.com
you say "it is not removing". Do you expect it to delete the files?

Mark Graves

unread,
Oct 7, 2014, 11:44:42 AM10/7/14
to web...@googlegroups.com
Hey Massimo,

Yes, I was expecting it to delete the old files similar to a normal SQLFORM update for an upload field. Then, the new blob would be stored with the obfuscated file name.

For example in the admin app, when you upload a new file, the old file is gone after the update completes.

I've dived into the source but I can't see anything that would do it.

Essentially, I was expecting uploadfs to change the methods on the field object as well to handle upload fields as if they were on the local file system.

Am I missing something?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/CZNxS9I222c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leonel Câmara

unread,
Oct 7, 2014, 1:29:25 PM10/7/14
to web...@googlegroups.com
I think Mark has a point. The way Set.delete_uploaded_files is defined right now forces you to implement a custom_delete if you want to do this, I think it should use the field's uploadfs.remove if autodelete=True and you have set the field's uploadfs.

We could put something like this in Set.delete_uploaded_files:

if field.custom_delete:
    field.custom_delete(oldname)
elif field.uploadfs:
    field.uploadfs.remove(oldname)
else:
    ... do the normal upload removal.

Mark Graves

unread,
Oct 8, 2014, 12:28:45 PM10/8/14
to web...@googlegroups.com
That is precisely what I was envisioning.  Perhaps this is a better discussion for the developer group?


--
Reply all
Reply to author
Forward
0 new messages