ob1y2k / publitio_js_sdk Goto Github PK
View Code? Open in Web Editor NEWSimple JS SDK for Publitio API
Simple JS SDK for Publitio API
When I run the example, this is what is logged. Did the API change?
{
success: false,
code: 400,
error: { message: 'Please include file or file_url in your request' }
}
In versions 1.0.9 and 1.0.10 after call uploadFile method, the library throws the error
ReferenceError: validateStatus is not defined
Code
const publitio = new PublitioAPI(process.env.PUBLITIO_API_KEY, process.env.PUBLITIO_API_SECRET)
...
const file = fs.readFileSync("uploads/" + req.file.filename)
publitio.uploadFile(file, 'file')
With version 1.0.8 works
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)
Hi there,
I'm trying to upload a video with hls option from that way:
const apiKey = "xxxx";
const apiSecret = "xxx";
const publitioClient = new PublitioAPI(apiKey,apiSecret);
try {
const data = await publitioClient.uploadRemoteFile({ file_url: url, privacy: 0, option_hls: 1 })
console.log(`Uploading finished. status code: ${data.code}`)
const dbData = {
finishedProcessing: true,
videoUrl: data.url_download,
thumbUrl: data.url_thumbnail,
aspectRatio: data.width / data.height,
publitioId: data.id,
}
return dbData;
}
catch (error) {
console.error('Uploading error');
console.error(error);
throw error;
}
But the problem is the video is private and the hls option is disabled:
What could be happen?
Best Regards
When trying out the example from the Readme with a 90MB wav file I get the following error:
{ Error: Request body larger than maxBodyLength limit
at RedirectableRequest.write (/some/path/node_modules/follow-redirects/index.js:97:24)
at RedirectableRequest.end (/some/path/node_modules/follow-redirects/index.js:116:8)
at dispatchHttpRequest (/some/path/node_modules/axios/lib/adapters/http.js:272:11)
at new Promise (<anonymous>)
at httpAdapter (/some/path/node_modules/axios/lib/adapters/http.js:20:10)
at dispatchRequest (/some/path/node_modules/axios/lib/core/dispatchRequest.js:59:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
...
According to this axios discussion it might be easy to fix by increasing the maximum content length (in bytes):
maxContentLength: 524288900 // 500MB
Trying to use this in a nodejs project.
Getting FormData is not defined
error while trying to upload a file.
Unlike browser, FormData needs to be added for use in nodejs apps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.