request direct upload sample

81 views
Skip to first unread message

arman...@gmail.com

unread,
Jan 2, 2017, 5:39:33 AM1/2/17
to Shrine
Hi

I need sample for direct upload with jquery file upload.
i need to method like update and create use one form like _form.html.erb
my problem is in javascript. i do every thing but ...



tanks


Janko Marohnić

unread,
Jan 2, 2017, 6:22:52 AM1/2/17
to Arman Emadi, Shrine
After the file is directly uploaded, you need to write the JSON data to the hidden attachment field (from the "Quick Start" section of the README). If you're directly uploading to the Shrine endpoint, then the JSON data will be returned in the response, so you can just write that to the hidden field. If you're directly uploading to Amazon S3, then you have to build the JSON data in JavaScript, like this.

I see now that the README doesn't mention this, I'll improve that. In the near future I might update the Rails example app so that it features just single upload were data submitted with the form, rather than multiple uploads.

Kind regards,
Janko

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.
To post to this group, send email to ruby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/8815cbcb-8696-4e43-8be7-89d2a6ecde5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

arman...@gmail.com

unread,
Jan 2, 2017, 7:06:07 AM1/2/17
to Shrine, arman...@gmail.com
tanks

sample is very important for deep understanding.
may be add crop on fly in sample to ;)


regards.

Janko Marohnić

unread,
Jan 2, 2017, 2:48:34 PM1/2/17
to arman...@gmail.com, Shrine
I unfortunately don't have time at the moment to create a sample, so you'll have to figure it out from the documentation and the information that I gave you.

Kind regards,
Janko
--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine...@googlegroups.com.

To post to this group, send email to ruby-...@googlegroups.com.

arman...@gmail.com

unread,
Jan 3, 2017, 5:39:46 AM1/3/17
to Shrine, arman...@gmail.com
hi again ,

at least tell me when i have _form.html.erb for update and create
what should i do ?

$.ajax("/album/photos", {method: 'POST', data: data}) .done(function(data) { $("ul").append(data) })

thinks when i have book model what should the above line be ?


regards

Janko Marohnić

unread,
Jan 3, 2017, 7:20:48 PM1/3/17
to Arman Emadi, Shrine
I'm assuming that you're doing common single uploads, that the form is for a record that has an attachment attribute. If you followed the "Quick start" section of the README, you have two attachment fields: a file field and a hidden field, which goes before the file field.

Then you don't send any additional AJAX requests (other than the ones required for direct upload), so instead of this code you just write the JSON data to the hidden field:

  var $hiddenInput = $(data.fileInput).prev();
  $hiddenInput.val(JSON.stringify(image));

I haven't tested the above code, but it should work. Then when you submit the form, the uploaded file represented by this data will be attached to the record.

Kind regards,
Janko

To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.

To post to this group, send email to ruby-...@googlegroups.com.

arman...@gmail.com

unread,
Mar 14, 2017, 3:46:12 PM3/14/17
to Shrine, arman...@gmail.com
Hi again

dear mr Janko Marohnić

my app is almost finished but i still have problem with crop and direct image upload to host with process bar and image preview
you saild you will create a simple sample for this.

I want to know if you create this !?

kindest regards

Reply all
Reply to author
Forward
0 new messages