Closed NicoloLattanzio closed 1 year ago
Hi @NicoloLattanzio
Could you please try to create a minimal (failing) example that we could actually run from a command line?
From your line above, it's hard for us to judge if you e.g. passed the correct type of argument to the uploadFromStream
function.
It expects a stream as second argument and we can't know from your example if "screenshot"
is a reference to a stream or not. Also note that the path
argument must be a relative, existing path, not a URL. (See https://github.com/tentwentyfour/nextcloud-link#core)
It says "argument type is not assignable to stream.Readable
I dont have a console error, it just dont upload
What do u mean with "existing path"? I'm trying to insert a folder with other file inside, into a nextcloud folder, im using the internal link as a path
I brlieve the function expects a stream, not a path. Is that correct?
Honestly, i'm not understanding what u mean with "stream"
Maybe something like this? const stream = fs.createReadStream('screenshot/ScreenshotAPP/kanban/de/2022-6-30 8356_kanban_de.png') await client.uploadFromStream("https://cloud.kanbanbox.com/index.php/f/938709",stream); But it's still not working
What about put
?
Already tried, but is it useful to upload file?
I'd assume so, but then again, I haven't touched the module in a while.
Idk, i did this but isnt working: await client.put("https://cloud.kanbanbox.com/index.php/s/***********","screenshot/ScreenshotAPP/kanban/de/2022-6-30 8356_kanban_de.png");
Oh right, sorry. The path you're passing is a network URL. You need to either dowbload the file OR create a HTTP stream that you'd use uploadFromStream
with
Mmmm what do u mean? I actually just need to upload it, so i think the thing missing is the stream, but i still dont understand what it is
Have a look at this: https://nodejs.org/api/stream.html
Stack Overflow might also help you here.
Please @NicoloLattanzio do not use github tickets as a form of chat. We are all trying to do our very best to concentrate both on our paid work and helping out, but receiving an email every 2 minutes isn't helping.
Please do not post again unless you can supply a complete source code snippet and the full error output that you see. Please also consider the following:
Your client
object is already connected (it should be, see our Getting Started section), as a given user, to your nextcloud server. Which means that https://cloud.kanbanbox.com/index.php
is irrelevant here.
If the user that you used to connect to your nextcloud server is for instance nicolo
, then the path that uploadFromStream
expects is the relative path, including the target filename to your user's home directory. No external or internal share links, but just the path. E.g. Documents/Images/Examples/image.png
.
If you don't know what a stream is, we suggest you read up on that in the node.js documentation.
Well, the full code i wrote is this: I'm trying both the function put and uploadstreamreadable, i tried to create the stream u were talking about but i guess this isnt the right way. By the way, where should i find the path? Like, i have just a folder called "Application Screenshot"
If you have one folder in your nextcloud instance and it is called "Application Screenshot", then you can use it as a target path. Also, the put
method accepts actual file content as the second parameter, not the path.
const content = fs.readFileSync('/path/somewhere/on/your/machine/screenshot.jpeg');
await client.put("/Application Screenshot", content);
Actually i did this, it works perfectly when loading a text file, but i cant load an image, as it need the image content(data), do u know how to do this? Or maybe there are other way to load an image ?
Hello, i just started using this library, but using this: await client.uploadFromStream("https://cloud.kanbanbox.com/index.php/f/938709","screenshot");
Doesnt do anything, shouldnt it upload the file?