Coder Social home page Coder Social logo

Comments (9)

hobigo avatar hobigo commented on August 16, 2024

Hi fatshotty,
this api has not been wrapped into the library yet.
I would put propose the following api with the most basic share to start with.

share:PublicShare = await file.createPublicShare();
doSomethingWith(share.url );

share:PublicShare = await folder.createPublicShare();
doSomethingWith(share.url );

Share:
url
resource: file | folder

Would that help? When do you need it?

https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html

from nextcloud-node-client.

fatshotty avatar fatshotty commented on August 16, 2024

hi, thanks for reply.
I think your example code is very good. However Nextcloud gives the possibility to choose the "shareType": public, user, group. And also the expiration date.
Will it be possible to include those features?

Thanks again

from nextcloud-node-client.

hobigo avatar hobigo commented on August 16, 2024

sure it is possible.
However, user and group classes are the prerequisite for that.
This would take a bit longer

from nextcloud-node-client.

fatshotty avatar fatshotty commented on August 16, 2024

thanks.
My need, now, is only public-share. Hope this can help :)

thanks

from nextcloud-node-client.

hobigo avatar hobigo commented on August 16, 2024

Hi,
new release 1.1.1 is available
it contains now public shares

   const file = await client.getFile("/products/MyFile.txt");
    // share the file (works also for folder)
    const createShare: ICreateShare = { fileSystemElement: file };
    const share: Share = await client.createShare(createShare);
    await share.setPassword("some password");
    await share.setNote("some note\nnew line");
    await share.setExpiration(new Date(2020, 11, 5));        
    await share.delete();

from nextcloud-node-client.

fatshotty avatar fatshotty commented on August 16, 2024

hi,
many thanks for new feature :)

one question:
const share: Share = await client.createShare(createShare);
Will this line create the 'public share' ? I mean:
with your example code I can create the 'share' resource and I can set password, note and expiration date.
I just need a public link. Should I only use the 'createShare( )' method?

Thanks

from nextcloud-node-client.

hobigo avatar hobigo commented on August 16, 2024

Hi,
thanks for the feedback.
I missed to document the most important part - the url.
Use the url of the share object to get the link.

createShare creates a share object. The object contains the url.

    const file = await client.getFile("/products/MyFile.txt");
    // share the file (works also for folder)
    const createShare: ICreateShare = { fileSystemElement: file };
    const share: Share = await client.createShare(createShare);
    // change share settings
    await share.setPassword("some password");
    await share.setNote("some note\nnew line");
    await share.setExpiration(new Date(2020, 11, 5));  
    // use the url to access the share 
    const shareLink:string = share.url;
    // delete share, if not required anymore
    await share.delete();

from nextcloud-node-client.

fatshotty avatar fatshotty commented on August 16, 2024

good job
thanks ;)

from nextcloud-node-client.

fatshotty avatar fatshotty commented on August 16, 2024

hi,
i'm trying to create a ShareLink as per your example.
It seems to work fine :)
I wonder: is there a way to get an already shared link for the same file?
I mean:

  • I can create share link to file /products/MyFile.txt and obtain its link -> OK
  • I need to read the share link (if exists) to file /products/OtherFile.txt
    • in case it doesn't exist -> create a new one
    • in case it exists -> get the already existing share link

Thanks

from nextcloud-node-client.

Related Issues (20)

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.