You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to upload a video file from a cordova app client using this code
function saveFile(filename, base64) {
var imgFile = new Parse.File(filename, {
base64: base64
})
$log.log('saving file ' + filename)
return imgFile.save()
}
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
var matches = dataUriRegexp.exec(_base.slice(0, commaIndex + 1));
// if data URI with type and charset, there will be 4 matches.
this._source = {
format: 'base64',
base64: _base.slice(commaIndex + 1),
type: matches[1]
};
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:
@dplewis looks like it should actually. And the changes I requested do seem to be in place. Thanks for pointing that out again. I'm marking to look at that when I get back tonight. Looks like the regex I suggested was put into place with some modifications for this PR, initially it looks good but I want to give it another look before I green light it.
Cross posted from parse-server issue #4388 on behalf of @lucamorelli.
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: