Comments (5)
Yeah.. thanks for doing this research. I had tracked most of this down at one point, and was aware that the file uploading wasn't working in safari, although I think I may have since forgotten that. Bummer.
There's a bit of a long story behind this, and now that I'm thinking about it, it's beginning to flood back. The reason for a lot of the extra file upload code is to avoid doing really hacky stuff in rails / rack.
I know you can easily send the whole file to the server, that's actually really really easy, and was part of my first pass at the file uploading javascript.. The not so easy part comes into play with how the server knows that it should do something with it. Right? So, for rails to know that it's something it cares about, the request must first make it through rack, with params set that rails can route, and then the controller takes over and uses those params to save a model / process the file.
While I was writing and playing around with the uploading code I was using a simple php script that would accept a file, and since php is pretty simple with things like that it was all fine.. The problem came up with when I switched it over to rails and tried to upload a file. It never made it through rack to the rails application, for obvious reasons -- there were no params to get the file information from. So, turns out that rails, via rack just disregards that file upload because it's totally not known to the rails server.. Nor is there any information about what that file is a property of (so saving a model and having paperclip do it's thing isn't possible).. In other terms, there no way to make that into a valid form submission without doing something nasty within rack. Right?
So enter awesomely annoying multi-part form building in javascript (took me about 8 hours to figure out and get working btw). You should poke around in that code and look at how the multi-part form is built.. Understanding that it's all there so Rails can process the file at a given route.
Basically, we could try to patch rack to handle that better (seems unlikely that would ever make it in though), or we work around it in the browsers where we can. Not sure of the best solution here, but if you can make rack/rails accept the file upload and route it properly with the right params I will adjust the javascript. ;-P
But seriously, I did spend about an hour playing around with a little rack app / metal layer that would try and grab that file, but gave up after a while because it felt dirty to me.. but maybe in hindsight not as dirty as the multi-part form stuff? I vaguely remember having to set several X- style headers to give rack the information it would need to pass it along to rails, and it just didn't feel right.
I'm going to put that in as a known issue for safari, and leave this issue open, but do you have any additional thoughts?
from mercury.
added the issue to https://github.com/jejacks0n/mercury/wiki/Known-Issues
from mercury.
My first thought would be: custom middleware. But I am writing this while I just woke up so I'll give it some more thought at work.
from mercury.
I don't have anything to add, just want future notifications on this. :)
from mercury.
Please help review this pull request: #184 Thanks!
from mercury.
Related Issues (20)
- Routes method is patch, can we do it?
- Is mercury stopped since 2013 dec? HOT 2
- How to prevent loading mercury.js on all pages?
- Paste image from clipboard
- Can we use mecury editor as docx editing tool ? HOT 1
- mercury editor blank page in heroku HOT 1
- Mercury2 normal html example ?
- Snippets with javascripts included HOT 1
- Snippet options not saved correctly [$15]
- Mercury2 on HTML
- Uncaught TypeError: Cannot read property 'stylesheets' of undefined
- /usr/local/rvm/gems/ruby-2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:238:in `add_request_method': You should not use the `match` method in your router without specifying an HTTP method. (ArgumentError)
- 34324
- bundler 1.13.1 objects to git protocol
- Section: Rails support in Readme.md? HOT 1
- How to remove mercury? HOT 1
- Neither install or post_install are working in Rails 5.2 HOT 2
- Regular Expression DoS vulnerability
- Mercury failed to load Live www.domain.com HOT 1
- Mode Set is closed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mercury.