question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to upload to uploadcare?

See original GitHub issue

Hello, after message to this awesome file uploader, he told me to post there.

Actually, I’m using this for upload to uploadcare server, which works:

pond.on('addfile', (error, file) => {
    if (error) {
        console.log('Oh no');
        return;
    }
    console.log('File added', file);
    var fileup = uploadcare.fileFrom('object', file.file);

And I was trying to get the progress bar of the upload, after asking to Rik, he told me better not use addfile for upload instead server.

But after checking server I have even more doubts…

This is the uploadcare rest doc: https://uploadcare.com/docs/api_reference/rest/requests_auth/ EDIT:

FilePond.setOptions({
    server: {
        //url: 'https://api.uploadcare.com/',
        process: {
            url: 'https://upload.uploadcare.com/base/',
            method: 'POST',
            withCredentials: false,
            headers: {
              	"Content-Type": "application/json"
            },
            timeout: 7000,
            onload: null,
            onerror: null
        }
    }

I’m using this configuration, but i’m having this error: POST https://upload.uploadcare.com/base/ 403 () But with post-man works good… In postman i add a param in the body: UPLOADCARE_PUB_KEY: demopublickey

But i don’t see where send body params in the server string.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rikschenninkcommented, Jul 10, 2018

The snippet I posted is an example from the docs, you’ll have to complete it. I’m planning to update the docs with a working custom implementation soon.

I don’t have any experience with uploadcare but by looking at the docs I would suspect the custom process funciton would look something like this:

FilePond.setOptions({
    server: {
        process: (fieldName, file, metadata, load, error, progress, abort) => {

            const upload = uploadcare.fileFrom('object', file);
            
            upload.progress((uploadInfo) => {
                // State of your upload gets updated.
                // The callback is invoked at least once with a current state,
                // right after assignment.
                // https://uploadcare.com/docs/api_reference/javascript/files_uploads/#upload-info
                progress(true, uploadInfo.uploadProgress, 1);

            });

            upload.done((fileInfo) => {
                // Upload has successfully completed and a file is ready.
                // https://uploadcare.com/docs/api_reference/javascript/files_uploads/#file-info
                load(fileInfo.uuid);

            })
            .fail((err, fileInfo) => {
                // Upload failed, or something else went wrong, a file is not ready.
                error(err);

            });
            
            return {
                abort: () => {

                    // https://uploadcare.com/docs/api_reference/javascript/files_uploads/#file-cancel-uploading
                    upload.cancel();

                    // Let FilePond know the request has been cancelled
                    abort();
                }
            };
        }
    }
});
0reactions
Yussan1commented, Jul 10, 2018

Still trying to implement just a “body” param, nothing…

I found this: https://github.com/pqina/filepond/issues/58 but there’s a thousand more data than what I need.

FilePond.setOptions({
    server: {
        url: 'https://www.filestackapi.com/api',
        process: {
            url: '/store/S3?key='+apikey+'',
            method: 'POST',
          	headers: {},
            withCredentials: false,
            timeout: 7000,
            onload: null,
            onerror: null
        }
    }
});

Which actually works, because it starts the upload, and it goes to 100% but I need send the file in body param.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading with Uploadcare
Uploadcare provides powerful File Uploader and Upload API for your website or app with no hassle.
Read more >
Quick start - Uploadcare
Uploadcare provides companies with simple, powerful, developer-friendly building blocks to handle file uploading, processing, and delivery.
Read more >
The complete guide to implementing file uploading - Uploadcare
Discover everything you need to know to implement file uploading capabilities in your app or website and collect images, videos and docs ...
Read more >
Docs File uploader - Uploadcare
Uploadcare File Uploader is a responsive and mobile-ready HTML5 website solution that allows users to select and upload multiple files from various sources....
Read more >
How to transfer your files to Uploadcare
This guide will help you copy your files from anoher storage to Uploadcare with the help of our Migro tool.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found