Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This bug is not fixed: examples/create-file.js returns error 'Please include file or file_url in your request' #18

Open
TimPchelintsev opened this issue Nov 8, 2021 · 3 comments

Comments

@TimPchelintsev
Copy link

This bug is not fixed... this error continue... please verify urgent. Thanks

{"success":false,"code":400,"error":{"message":"Please include file or file_url in your request"}}

let formData = new FormData();
    formData.append("file", file);

    if (file == undefined) {
      console.log("Choose file to upload first");
      return;
    }

    const api_url = publitio.uploadUrlSigned();

    this.axios
      .post(api_url, formData, {
        headers: {
          Accept: "application/json",
          "Content-Type": "multipart/form-data",
        },
        onUploadProgress: function (progressEvent) {
          const valeur = Math.round((progressEvent.loaded / progressEvent.total) * 100);
          console.log(valeur + "%");
        }.bind(this),
      })
      .then(function (response) {
        console.log(response.data);
        if (response.data.success == true) {
          console.log("upload ok");
        } else {
          console.log("upload failed");
        }
      });

Originally posted by @ednsinf in #17 (comment)

@TimPchelintsev
Copy link
Author

It seems to work after removing "Content-Type": "multipart/form-data" header.

@ob1y2k
Copy link
Owner

ob1y2k commented Nov 10, 2021

Did you updated to the latest js sdk version 1.1.5 ?

Also if file is >5GB you can get that error

And file must have .ext in the end

@TimPchelintsev
Copy link
Author

Hey @ob1y2k, sorry for late response.

Well, I am on the latest version and try to upload small video file with extension. As I mentioned, removing header makes it work. So now I successfully deployed this stuff. I am not very experienced in file uploads, so I cant say if this header removal will kick me later. At least I am able to show progress bar and upload files like 1GB. I spent some very uncomfortable time trying to fix bug though - as I copied documentation example and got error.

@TimPchelintsev TimPchelintsev changed the title This bug is not fixed... this error continue... please verify urgent. Thanks This bug is not fixed: examples/create-file.js returns error 'Please include file or file_url in your request' Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants