putdotio / putio-js Goto Github PK
View Code? Open in Web Editor NEWJavaScript SDK for interacting with the put.io API.
License: MIT License
JavaScript SDK for interacting with the put.io API.
License: MIT License
With an index.js
like this:
import PutioAPI from '@putdotio/api-client'
const putioAPI = new PutioAPI({ clientID: 'OAUTH_CLIENT_ID' })
and the following package.json
:
{
"name": "putio-test",
"version": "1.0.0",
"description": "Test for put.io API client library",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"@putdotio/api-client": "^8.16.0"
}
}
I receive the following error:
file:///putio-test/index.js:3
const putioAPI = new PutioAPI({ clientID: 'OAUTH_CLIENT_ID' })
^
TypeError: PutioAPI is not a constructor
at file:///putio-test/index.js:3:18
at ModuleJob.run (internal/modules/esm/module_job.js:110:37)
at async Loader.import (internal/modules/esm/loader.js:176:24)
when using node >=13 or 12 with the --experimental-modules
flag.
The API documentation notes that file_type
is an available filter on the /files/list endpoint, but it is not implemented at https://github.com/putdotio/putio.js/blob/master/src/resources/Files/Files.ts
as per axios it looks like the post request does not hit upload.put.io
. Instead, it hits api.put.io
Some of the methods are out of date and are no longer available from the API. For example File.Delete()
does not work, and Files.Delete()
should be used instead.
I'll hopefully make a PR to clean up some of that soon.
Hi, I do not understand what I am doing wrong. I initialize the API client like this
const putioConfig = this.configService.get('putio');
this.api = new PutioAPI({
clientID: putioConfig.clientId,
});
this.api.setToken(putioConfig.oAuthToken);
with this API when I call the Account.Info()
it works perfectly as expected.
const accountInfo = await putio.Account.Info();
this.logger.log(`Uploading as ${accountInfo.data.info.username}`);
However when I call the Files.Upload(...)
I get 401
await api.Files.Upload({
file: absolutePath,
fileName: filename,
parentId: targetFolderId,
});
is there some issue with the sdk
or am I doing something wrong?
Could you add an Upload
method to the File or Files class? This would really be useful on my CLI client.
I would understand if you consider it to be outside of the scope of the library though.
> shx rm -rf dist && tsc -b
node_modules/@putdotio/api-client/dist/resources/Auth/types.d.ts:1:31 - error TS2307: Cannot find module 'utils/types' or its corresponding type declarations.
1 import { ISODateString } from 'utils/types';
~~~~~~~~~~~~~
Found 1 error.
I cannot use this library in my application without setting strict:false
or skipLibCheck:true
in my tsconfig becuase this library contains type errors. I suggest adding this option, then fix all of the errors reported by TypeScript compiler.
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.