Rails 4: upload attachments to Amazon S3 before saving model -


i have feature users can add notes, , every note can have multiple file attachments.

when user clicks 'upload attachment', file begins uploading amazon s3 instantly (before users save note). done ajax.

what best way (flow) make sure these amazons3 files linked note (when note submitted) or discarded if note isn't saved?

i can think of 2 approaches:

  1. go ahead , save note, have column on model tells whether or not it's temporary. if user clicks save, change column temporary permanent. run rake task in background clear out temporary notes more day old, etc., if wanted that.

  2. put sort of reference in image's file name. can't use id, since won't exist yet, may have other unique identifiers such combination of username , post title.

if can 1st option, i'd preferable. gives unique id note, has express purpose of making possible reference note externally.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -