Issue #3042Opened September 23, 2020by patoperpetua0 reactions

FEAT: Accurate Documentation on uploadFile

Question

WARNING

READ and FOLLOW next 3 steps, then REMOVE them before posting the issue

  1. Follow CONTRIBUTING Guidelines https://github.com/artf/grapesjs/blob/master/CONTRIBUTING.md
  2. Do a quick SEARCH first, to see if someone else didn't open the same issue
  3. All relative statements/questions have to be filled/answered, otherwise, the issue might be CLOSED
  4. JSFiddle Starter template https://jsfiddle.net/szLp8h4n
  5. CodeSandbox Starter template https://codesandbox.io/s/1r0w2pk1vl

What are you trying to add to GrapesJS? Add more documentation to uploadFile and also create a function to upload files by providing a URL.

Describe your feature request detailed So, basically I want to add more documentation to the first parameter of uploadFIle function and to add another function to save files just by providing the URL. I've already done this, you can see at the bottom of this issue.

Is there an alternative at the latest version?

[ ] Yes (describe the alternative) [X] No

Is this related to an issue?

[ ] Yes (Give a link to the issue) [X] No


In File FileUploader.js

...
/**
     * Upload files
     * @param  {Object}  e Event OR an array of file objects.
     * @return {Promise}
     * @private
     * */
    uploadFile(e, clb) {
        const files = Array.isArray(e)? e : e.dataTransfer ? e.dataTransfer.files : e.target.files;
   ...
/**
     *
     * @param url
     * * @param name
     */
    async uploadFileURL(url, name){
      const response = await fetch(url);
      // here image is url/location of image
      const blob = await response.blob();
      const file = new File([blob], name, {type: blob.type});
      this.uploadFile([file]);
    }

If you want I can create a pull request with it.

Answers (2)

no-response[bot]October 19, 20200 reactions

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.