Priority-web-sdk: uploadImage
I am trying to upload an image from uploadImage from the documentation. The first thing I notice is that this method does not appear to be an open package.
There is a method with a very similar signature uploadDataUrl
that I use in the code below, but I cannot tell if the usage is identical.
Here's a complete example of my test page here .
save(curform) {
return new Promise((resolve, reject) => {
curform.uploadDataUrl("{0}{1}".f(this.postURL, this.filename), "png").then(uploadResult => {
if (uploadResult.isLast == 1) {
// Save the upload result with fieldUpdate.
} else {
var er = {};
er.message = "Don't know what happened...";
reject(er);
}
}).catch(er => { reject(er) })
})
}
FileUploadResult looks like this:
JSONObject {jsObject: Object, progress: 100, isLast: false}
Obviously, if the upload was successful, the FileUploadResult should contain file.Key
and file.Value
.
Any suggestions please?
source to share
First of all, the function name is valid uploadDataUrl
. We will update the documentation. Thank.
Second, the record is file
returned after success. Don't use Promise
here, because in this case the response is returned multiple times with a different progress value each time. Use callbacks instead.
source to share