-
-
Notifications
You must be signed in to change notification settings - Fork 596
Creating a Parse.File with base64 string fails #1510
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
Thanks for opening this issue!
|
Could you submit a PR with a failing test to reproduce the issue? |
It seems this is the issue that is causing the issues here. Trying to save a Parse File with a base64 string of Failing test can be as simple as: it('can create basic files', async () => {
const buffer = Buffer.from('Hello World!');
const file = new ParseFile('hello.txt', {base64: buffer.toString('base64')}, 'text/plain'); // fails here
expect(file._source.base64).toBe('SGVsbG8gV29ybGQh');
expect(file._source.type).toBe('text/plain');
}) The problematic regex is:
|
Did you find out what the problem is with the regex? |
It seems you are right, but the regex in your example does not seem correct, because we'd still strictly expect padding when encoding a 16 bit group. The issue with the current regex seems to be that it doesn't expect to encode a string that is exactly a multiple of 3:
The fixed regex that accounts for that would be:
If we want to be even stricter, we can use the following, because padding assumes a defined set of prefixes:
I think we should also make sure that we have tests which encode a string:
If you could add the regex fix to your PR and add the tests, we should be able to close this issue. |
@DennisVanAcker1 Please make sure you are using the Parse JS SDK version which contains the fix, see #1543. If the issue still exists despite you using the alpha version, please open a new issue. |
Will do! thanks again, should have looked into this abit more before posting. |
New Issue Checklist
Issue Description
When Calling new Parse.File with the versions 3.4.1 upwards the process takes a few mins then actually throws an error saying
"Cannot create a Parse.File without valid data URIs or base64 encoded data."
Steps to reproduce
Calling Parse.file with the file blob will reproduce the issue
Actual Outcome
an error gets thrown saying: "Cannot create a Parse.File without valid data URIs or base64 encoded data."
Expected Outcome
getting a Parse File back
Environment
not a server issue but =>
Server
n/a
n/a
n/a
Database
n/a
n/a
n/a
Client
3.4.3
Logs
The text was updated successfully, but these errors were encountered: