3

I'm trying to upload an image using uploadImage from the documentation. The first thing I notice is that the method does not seem to be exposed by the package.

There is a method with a very similar signature uploadDataUrl, which I'm using in the code below, but I can't tell if the usage is identical.

There's a full 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) })
    })
}

The FileUploadResult looks like this:

JSONObject {jsObject: Object, progress: 100, isLast: false}

Obviously if the upload was successful there should be file.Key and file.Value in the FileUploadResult.

Any suggestions please?

1 Answers1

0

First of all, the name of the function is uploadDataUrl indeed. We will update the documentation. Thank you.

Second thing, the file entry is returned upon success. Don't use Promise here because in this case the response is returned several times with different progress value each time. Use callbacks instead.

neomib
  • 3,503
  • 4
  • 17
  • 27