-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
possible bug creating new File #4388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What version of parse-server? |
latest version, the packages of the app are updated |
You need to remove the "data:video/mp4;base64,". Check the docs http://docs.parseplatform.org/js/guide/#files |
I see two constructor in the File class: one accept the filename and all the data as base64 string, and this works correctly with jpg, png files and so, and another where I can remove this part but I have to send the content type as third param. I already made this change as a workaround, but I don't understand why the first constructor works with just some content type giving this unclear error message |
Maybe @flovilmart can be give to you a better response. |
@lucamorelli that looks about right. I swear I've seen this somewhere else in one of the sdks as well, in terms of a regex parsing a content-type and not expecting a digit in the second half. Can you provide a link to where this is in the server so I can take a look? |
This is the line where the regexp is declared and here where I have the problem |
It’s in the JS SDK, please open an issue on this project instead. Thanks! |
@lucamorelli I went ahead and opened up #517 in the JS sdk regarding this so we can address it there. |
Issue Description
I'm trying to upload a video file from a cordova app client using this code
this code works uploading files, but fails sending a video, where I have a base 64 string starting with
data:video/mp4;base64,AAAAGGZ0eXBtcDQyAA
.I checked the code and I think I found the problem
this is the regexp that extract the file content
var dataUriRegexp = /^data:([a-zA-Z]*\/[a-zA-Z+.-]*);(charset=[a-zA-Z0-9\-\/\s]*,)?base64,/;
here tries to extract the content type from the datastring
this control fails when the content type contains a number like mp4, and the matches array is null
changing the regexp to
var dataUriRegexp = /^data:([a-zA-Z]*\/[a-zA-Z0-9+.-]*);(charset=[a-zA-Z0-9\-\/\s]*,)?base64,/;
seems to work
Steps to reproduce
try to create a un file object using the filename, and a full base64 data string containing a content type with a number like video/mp4
Expected Results
to be able to save file with this content type
Actual Outcome
error evaluting the matchs array because is null
The text was updated successfully, but these errors were encountered: