-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
CSV file upload breaks if whitespace in filename #427
Comments
Unsure how to even test for this
but the spec exercising this part of the code returns this
so the spec isn't working with the same problematic field - namely file_upload.js generates the URL name like so var key = $(data.jqXHR.responseXML).find("Key").text();
var url = 'https://' + form.data('host') + '/' + key; in the formdata this looks like so "formData": {
"key": "uploads/fbaff82b-b35e-40d0-bbb0-0df47aa15a1f/${filename}",
} a simple regex swapping whitespace for dashes will not catch cases where a user uploads a file with trailing whitespace before the .csv extension |
This is unbelievably exasperating. No function analagous to parametricize exists in jQuery. It seems to me like catching this error within the JS file |
It's possible that the error encountered has little to do with amazon s3 or otherwise and may entirely relate to this issue within the CSVlint gem Data-Liberation-Front/csvlint.rb#182 |
I've started investigating this from another direction, driving out with specs. Got some of it working by encoding/decoding URLs properly, but the S3 interface isn't fully tested by the specs, I think, so it'll need a combination of our two approaches, I think. |
By combination of approaches do you mean the one you're working on PLUS the bug within the csvlint gem? |
And the branch you were working on as well. [EDIT] oh that's this one, so yeah. :) |
So. The CSVlint issue only affects local files in the command-line client, but the reason is similar. The CSVlint validator expects valid URLs to be passed in, whether file URLs, or http. The problem we're having here, I think, is that the uploader is giving us back an invalid (i.e. not correctly encoded) URL when we upload a file with a space in it. We need to detect that and encode, somewhere. |
So as soon as the file is uploaded, the URL in the file uploader has a space in it. This feels wrong. |
I'm now taking another approach to this. There is no reason to turn the S3 storage key into a URL and back again, so I'm going to change it to just pass along as a key instead. Let's see if that helps. |
Context there: the storage keys work fine with spaces in. It's only because we're turning them into URLs for some of the time that the code fails. |
Success acheived in #567. |
Steps to reproduce
Upload any CSV contain
WORD \s WORD.csv
to Octopub publication. Upload should hangLogs should show:
Completed 500 Internal Server Error in 45ms (ActiveRecord: 5.1ms) (etc.)
URI::InvalidURIError (bad URI(is not URI?): https://octopub-dev.s3-eu-west-1.amazonaws.com/uploads/eac6e230-05db-47ed-9454-c2c143b83c98/WORD WORD.csv):
The text was updated successfully, but these errors were encountered: