I get following error while uploading my profile img:
cannot create a parse file without valid data URL or base64 encoded data
It only happens after uploading a few times, mostly around the third time.
It happens when new Parse.File(fileName, { base64 })
is called.
Is there something i am doing wrong, how can i work around this?
public async takePicture() {
this.photo = await Camera.getPhoto({
quality: 100,
width: 256,
allowEditing: false,
resultType: CameraResultType.Base64,
})
return { ...this.photo }
}
public async uploadPicture() {
if (this.photo) {
const base64 = this.photo.base64String
// Save photo to backend
const fileName = this.accountService.getUserFirstName() Date.now() ".jpg"
try {
const parseFile = new Parse.File(fileName, { base64 })
const response = await parseFile.save()
await this.accountService.setProfilePicture(response)
} catch (err) {
console.log(err)
alert(err)
}
}
}
CodePudding user response:
The issue has been fixed, but currently only released as version 3.5.0-alpha.2. You are using an old version 3.4.3
, so the issue still occurs.
You can fork Parse Server and use the fixed alpha version of the Parse JS SDK to make it work, or wait until the release of Parse Server with the fixed version.