tinymce / tinymce-react

Offical TinyMCE React component
MIT License
938 stars 151 forks source link

Unable to see blob content via images_upload_handler #359

Closed yingying96 closed 2 years ago

yingying96 commented 2 years ago

Hi Team,

I'm trying to implement images_upload_handler on react js but i am having trouble seeing the blob content. However, i am able to get size, type and filenames of the blob.

          images_upload_handler: function UploadHandler(blobInfo, success, failure) {
            // eslint-disable-next-line no-undef
            const imageFile = new FormData();
            imageFile.append('files[]', blobInfo.blob());

            const data = {
              thumbHeight: blobInfo.blob().thumbHeight,
              thumbWidth: blobInfo.blob().thumbWidth,
              file: imageFile,
              fileName: blobInfo.blob().fileName,
              fileType: blobInfo.blob().fileType,
            };

            try {
              // const { data } = await axios.post(`${API_URL.storage}`, imageFile);
              // success(data.fileURL);
            } catch (error) {
              console.log(error);
            }
          }
exalate-issue-sync[bot] commented 2 years ago

Ref: INT-2941

yingying96 commented 2 years ago

Found the answer: blobInfo.base64()