Coder Social home page Coder Social logo

hobigo / nextcloud-node-client Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 13.0 7.3 MB

Nextcloud node.js client for TypeScript and JavaScript

Home Page: https://hobigo.github.io/nextcloud-node-client/

License: Apache License 2.0

TypeScript 100.00%
nextcloud nodejs typescript

nextcloud-node-client's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar hobigo avatar klpprd avatar scrounger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nextcloud-node-client's Issues

Image Preview Link

Hey great package! I've been playing around with this and was wondering is there is anyway to get the preview link for image files?

Thanks.

Incorrect/missing URL encoding

Describe the bug
Methods such as client.getFolderContents fail to generate properly URL encoded requests, resulting in HTTP 500 responses.

To Reproduce
Steps to reproduce the behavior:

  1. Create a folder or file containing umlauts (ä, ö, ü...) or certain characters with special meanings in URLs (e.g. '+')
  2. Try to query this folder using methods such as client.getFolderContents

Expected behavior
The API is supposed to generate properly encoded URLs for HTTP requests to the nextcloud instance, resulting in appropiate and expected HTTP responses. For client.getFolderContents, a list of folder contents of the specified folder should be returned.

Additional context
Pulled this lib directly from NPM, version according to package.json is 1.8.1.

getPercentCompleted returns only 0 and 100

Hey there...

I was just trying to async upload a larger video file following your example here:
https://github.com/hobigo/nextcloud-node-client/blob/master/docs/upload.md

But the console log only returns 0 or 100 when using the getPercentCompleted() command?

My Code:

let files = [{ sourceFileName: sourceFile, targetFileName: targetFile }];
let uc = new UploadFilesCommand(newClient, { files });
uc.execute();
while (uc.isFinished() !== true) {
    await (async () => { return new Promise(resolve => setTimeout(resolve, 1000)) })();
    console.log(uc.getPercentCompleted() + "%");
}

const uploadResult = uc.getResultMetaData();

if (uc.getStatus() === CommandStatus.success) {
    console.log(uploadResult.messages);
    console.log(uc.getBytesUploaded());
} else {
    console.log(uploadResult.errors);
}

Here is my output:
0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 100% [ '/video.mp4' ] 80275042

Or is this correct and it only returns IF the command UploadFilesCommand was completed? Sounds weird to me and is not really what I would expect. I would like to show the percentage of the file in progress.

Get share information

Is your feature request related to a problem? Please describe.
We would like to find out if a share for a file or folder already has been created, before we create another one. As far as I can tell, this is not possible.

Describe the solution you'd like
Instead of using createShare to get the share.url, I think it would be better to have a command like getShareInfo or such and call this API as described here: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html#get-shares-from-a-specific-file-or-folder

Regards and thanks alot for this great package!!

Please document how to set up & build the project

Is your feature request related to a problem? Please describe.
I checked out the project and ran npm install and npm run build and got 204 typescript compiler errors. I can't find any information in this project which node version I should use and whether I need to do more steps to achieve a working compile.

Describe the solution you'd like
Please write a short how-to on how to set up this project for development.

Describe alternatives you've considered
You could make it "just work" ;)

Thanks for your time.

create a share link of a file

hello, i'm using your lib for the first time. I need to create share-link of a file but I cannot find API.
Is there a way to do that?

Thanks in advance.

Describe the bug
create share-link of a file

To Reproduce

Expected behavior
An API call to create share-link of the file

Additional context

getFolder() always return null

Describe the bug
When calling getFolder function, it always return null

To Reproduce

  1. Create new client object
  2. Call getFolder with a folder name as parameter

Expected behavior
Receive a Folder object if the folder exist

Fuse/Merge with tentwentyfour/nextcloud-link ?

Hi Holger,

just wanted to get in touch with you – and this is the only way we found – to discuss a possible collaboration and possibly the route to a merger of nextcloud-node-client and https://github.com/tentwentyfour/nextcloud-link

We might be able to get there faster if we collaborate, rather than building the same thing twice. If you're interested, let's discuss specifics. Get in touch with us a hello {at} tentwentyfour.lu (DE/EN)

Compatibility with node 10

Hey is your library compatible with node 10 or more ?

I always have this error when i try to install it !

[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
error [email protected]: The engine "node" is incompatible with this module. Expected version "8.x". Got "10.16.3"
error Found incompatible module.

Thank you

send notification - missing url encoding

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

publicUpload does not work

Describe the bug

const subfolder: Folder = await folder.createSubFolder('test');
const createShare: ICreateShare = {fileSystemElement: subfolder, publicUpload: true};
const share: Share = await client.createShare(createShare);
const shareLink: string = share.url;

Share URL should allow to upload files anonymously - it does not work.
Tested with Nextcloud 19.

Copy Folders with content

Is your feature request related to a problem? Please describe.
Currently I don't find a way to copy files or folders from one nextcloud path to another. I can only find a only move command.

Describe the solution you'd like
A copyFolder and or copyFile command would be great. Alternatively a "best practice copy showcase" based on the current library would be great!

Describe alternatives you've considered
I didn't find alternatives besides downloading and re-uploading (which I haven't tried yet).

Additional context

file search

https:///core/search?query=&inApps%5B%5D=files&page=1&size=30
https:///core/search?query=&inApps[]=files&page=1&size=30

response
id: 27813
link: "/apps/files/?dir=/...."
mime_type: "application/json"
modified: 1581859191
name: "20191231_102725.json"
path: "/......./20191231_102725.json"
permissions: 27
size: 220
type: "file"

Error: unable to verify the first certificate

Describe the bug
Getting this error:
https://xx.xx.xx.xx/ocs/v2.php/apps/serverinfo/api/v1/info?format=json failed, reason: unable to verify the first certificate

To Reproduce
Using the following code:

			const api = require('nextcloud-node-client');

			const server = new api.Server({
				basicAuth:
				{
					username: "test",
					password: "xxxx",
				},
				url: "https://xx.xx.xx.xx/remote.php/webdav",
			});

			const client = new api.Client(server);

			const sys =  await client.getSystemInfo();
			this.log.info(sys.nextcloud.system.version);

I use as self signed certficat, perhaps this is the reason?
On other apps that communicate with nextcloud has option to accept self signed certificates.
Is there also such a option in the api?

Getting TypeError: Client is not a constructor

Describe the bug
When trying to initialize the client like this:

import Client from "nextcloud-node-client";

const client = new Client();

I get:

file:///C:/Users/ilja/Desktop/Projects/Development/Other/Plugins/steam-cloud-sync/nct.js:3
const client = new Client();
               ^

TypeError: Client is not a constructor
    at file:///C:/Users/ilja/Desktop/Projects/Development/Other/Plugins/steam-cloud-sync/nct.js:3:16
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12)

To Reproduce

  1. Make a new JS/TS file (with the latest node version)
  2. Import and initialize the client constructor

Expected behavior
Client should get initialized without any trouble

Additional context
Tried it with various TS configs and JS EMS syntax

Javascript examples

I cannot make the library to work in javascript node application.
All examples are in typescript.

Could you please provide a couple of examples on how to create a client in vanilla javascript?

Issue in deleting folder/file immediately after its creation.

I am trying to do unit testing using Jest to test functions of creating folder and deleting folder from the next cloud.
I can create the file/folder successfully but when I end the test to delete it immediately I got an error says

{
  code: 'ERR_UNEXPECTED_HTTP_STATUS',
      context: {
        expectedHttpStatusCodes: [ 204 ],
        responseStatus: 423,
        responseStatusText: 'Locked'
      }
}

I think the reason is that the file is locked and needs some time to be able to delete it, I tried many solutions but did not worked out.
Is there any option can I include in the body request to override this rule?.

feature

Hi, I read the source code of the library, and could not find how to create a share with particular users. but I am allowed to create share.
how can I specify with which user this folder will be shared?.

client.getQuota() does not return the correct quota

Describe the bug
client.getQuota() returns two numbers that are not the real available or used quota of the user. These two numbers are from two separated entries of the PROPFIND command issued inside the getQuota() call.

To Reproduce
Steps to reproduce the behavior:

  1. create a user with a specific quota, an fill in some files and folders
  2. get the quota of that user:
const ncc = require( 'nextcloud-node-client');
const server_data = { basicAuth: { username: auth.username, password: auth.password }, url: server_url, };
const server = new ncc.Server( server_data );
const client = new ncc.Client( server);
const user_quota = await client.getQuota();

Correction
after looking into the code:

  public async getQuota(): Promise<IQuota> {
    log.debug("getQuota");
    const requestInit: RequestInit = {
      method: "PROPFIND",
    };

    const response: Response = await this.getHttpResponse(this.webDAVUrl + "/", requestInit, [207], { description: "Client get quota" });
    ...

In requestInit it seems that headers: new node_fetch_1.Headers({ "Depth": "0" }), is missing.
With

    const requestInit: RequestInit = {
      method: "PROPFIND",
      headers: new node_fetch_1.Headers({ "Depth": "0" }),
    };

it returns the expected result.
client_patch.txt

Support for UserGroup shares

Is your feature request related to a problem? Please describe.
Shares for UserGroups are not implemented yet. I would like to work with them making use of this fine library.

Describe the solution you'd like
Implementation of sharing for user groups.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.