Comments (4)
Hi michimau,
what is JavaScript? :-)
I would strongly recommend to switch to TypeScript.
However, import and require with defaults is a mess - I will fix that in Version 2.
Remove the typings in the example code and use this line to get the client
const Client = require("nextcloud-node-client").Client;
Find the js example example below.
Regards Holger
// tslint:disable:no-console
// get files recursively
const Client = require("nextcloud-node-client").Client;
(async () => {
const client = new Client();
const sourceFolder = await client.getFolder("/Borstenson/Company Information");
if (!sourceFolder) {
console.log("source folder not found");
process.exit(1);
}
// only pdfs and jpg should be listed
const fileFilterFunction = (file) => {
if (file.mime === "application/pdf" || file.mime === "image/jpeg") {
return file;
}
return null;
}
const options = {
sourceFolder,
filterFile: fileFilterFunction,
};
const command = new GetFilesRecursivelyCommand(client, options);
// get files asynchronously (will not throw exceptions!)
command.execute();
// check the processing status as long as the command is running
while (command.isFinished() !== true) {
// wait one second
await (async () => { return new Promise(resolve => setTimeout(resolve, 1000)) })();
console.log(command.getPercentCompleted() + "%");
}
// use the result to do the needful
const commandResult = command.getResultMetaData();
if (command.getStatus() === CommandStatus.success) {
console.log(commandResult.messages);
for (const file of command.getFiles()) {
console.log(file.name);
}
} else {
console.log(commandResult.errors);
}
})();
from nextcloud-node-client.
thank you 1000: https://gist.github.com/michimau/5b8deb6a2c98a6a9c68d4ea4c3d5b9a0
I cannot make this to work tho:
const client = new Client("http://localhost:8002", { username: "admin", password: "changemeXX" } );
what is wrong there?
from nextcloud-node-client.
Hi,
here's the info: https://github.com/hobigo/nextcloud-node-client#creating-a-client
replace line 11 with the following code
const server: Server = new Server(
{ basicAuth:
{ password: "<your password>",
username: "<your user name>",
},
url: "https://<your nextcloud host>",
});
const client = new Client(server);
from nextcloud-node-client.
Brilliant, thanks!
from nextcloud-node-client.
Related Issues (20)
- Issue in deleting folder/file immediately after its creation. HOT 2
- feature
- Getting TypeError: Client is not a constructor HOT 2
- Please document how to set up & build the project
- Support for UserGroup shares
- new feature: searchFilesByTag HOT 8
- file search
- uploadFolderCommand endless loop if folder does not exits
- getSubfolders returns original folder if folder name contains blanks
- getFolder() always return null
- publicUpload does not work HOT 5
- node-fetch types are not exported in fakeServer and http clienent
- Copy Folders with content HOT 3
- client.getQuota() does not return the correct quota
- Is it possible to upload a file on disk to nextcloud?
- Get share information HOT 1
- Is there any plan to re-open this?
- Incorrect/missing URL encoding HOT 1
- getPercentCompleted returns only 0 and 100
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextcloud-node-client.