stavro / arc_ecto

An integration with Arc and Ecto.
255 stars 149 forks source link

JSON Resource uploading #50

Open SuperDisk opened 8 years ago

SuperDisk commented 8 years ago

The example in the README.md walks you through uploading a file using a HTML <form>. How do you post a file and other attributes to a JSON api?

joshsmith commented 8 years ago

@SuperDisk I handle this in https://github.com/code-corps/code-corps-api by uploading files as base 64 strings.

I'm not super satisfied with this since I'm on Heroku and large files result in time outs. I'd prefer if I could upload to S3 directly and have arc_ecto (somehow!?) be used for reference.

stavro commented 8 years ago

@JoshSmith I have direct-to-s3 uploads working locally. I'll push it to Arc soon.

joshsmith commented 8 years ago

@stavro that's amazing and will be wonderful to see. Happy to help how I can since it's a major pain point here.

stavro commented 8 years ago

@SuperDisk I highly recommend sticking to multipart file uploads rather than JSON. This is trivial with Angular and most other frontend clients. Uploading files via JSON is using the wrong tool for the job IMO.

joshsmith commented 8 years ago

I will also say that even though our implementation works, I really dislike it. It feels ham-fisted, as @stavro said – wrong tool for the job.

stavro commented 8 years ago

@JoshSmith

Here's an open branch: https://github.com/stavro/arc/pull/125 Here's some documentation: https://github.com/stavro/arc/wiki/Direct-to-S3-Uploads

Feel free to start playing with it, though I have a lot more to document. Especially surrounding content disposition.

joshsmith commented 8 years ago

@stavro thanks for this! Are you in the Elixir community Slack by chance? I'd tried looking for you there previously but no joy.