Share a single item publicly #2

Closed
opened 2021-12-12 00:28:39 +00:00 by adam · 2 comments
adam commented 2021-12-12 00:28:39 +00:00 (Migrated from git.theadamcooper.com)

(This is here mostly to keep track of API request syntax.)

  • Request for shared items from a folder (not useful?):
    curl -u "adam:password" --header "OCS-APIRequest: true" 'https://theadamcooper.com/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?path=public/2014_public&subfiles=true'

  • Request for all items from a folder:

curl -u "adam:password" 'https://theadamcooper.com/nextcloud/remote.php/dav/files/adam/public/2015_public' -X PROPFIND --data '<?xml version="1.0" encoding="UTF-8"?>
 <d:propfind xmlns:d="DAV:">
   <d:prop xmlns:oc="http://owncloud.org/ns">
     <d:getlastmodified/>
     <d:getcontentlength/>
     <d:getcontenttype/>
     <oc:permissions/>
     <d:resourcetype/>
     <d:getetag/>
     <oc:share-types/>
   </d:prop>
 </d:propfind>'
  • Sample response including shared and non-shared files:
<?xml version="1.0" encoding="UTF-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:s="http://sabredav.org/ns">
    <d:response>
        <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/</d:href>
        <d:propstat>
            <d:prop>
                <d:getlastmodified>Sun, 25 Apr 2021 19:59:42 GMT</d:getlastmodified>
                <oc:permissions>RGDNVCK</oc:permissions>
                <d:resourcetype>
                    <d:collection />
                </d:resourcetype>
                <d:getetag>"6085ca2e0875a"</d:getetag>
                <oc:share-types>
                    <oc:share-type>3</oc:share-type>
                </oc:share-types>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
        <d:propstat>
            <d:prop>
                <d:getcontentlength />
                <d:getcontenttype />
            </d:prop>
            <d:status>HTTP/1.1 404 Not Found</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0912.JPG</d:href>
        <d:propstat>
            <d:prop>
                <d:getlastmodified>Mon, 01 Mar 2021 04:37:44 GMT</d:getlastmodified>
                <d:getcontentlength>2259216</d:getcontentlength>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <oc:permissions>RGDNVW</oc:permissions>
                <d:resourcetype />
                <d:getetag>"371dd82abd34a3d42e8bec4b4f69e150"</d:getetag>
                <oc:share-types>
                    <oc:share-type>3</oc:share-type>
                </oc:share-types>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0913.JPG</d:href>
        <d:propstat>
            <d:prop>
                <d:getlastmodified>Sun, 14 Jun 2015 19:01:09 GMT</d:getlastmodified>
                <d:getcontentlength>2302335</d:getcontentlength>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <oc:permissions>RGDNVW</oc:permissions>
                <d:resourcetype />
                <d:getetag>"f4a24da1d0a0ef1c01e591860f8b0c26"</d:getetag>
                <oc:share-types />
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0914.JPG</d:href>
        <d:propstat>
            <d:prop>
                <d:getlastmodified>Mon, 30 Mar 2020 00:04:09 GMT</d:getlastmodified>
                <d:getcontentlength>2316042</d:getcontentlength>
                <d:getcontenttype>image/jpeg</d:getcontenttype>
                <oc:permissions>RGDNVW</oc:permissions>
                <d:resourcetype />
                <d:getetag>"647dc6d6eced748effe7c6537b5b7c62"</d:getetag>
                <oc:share-types />
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>
  • Request to share a file/folder:
curl -u "adam:password" --header "OCS-APIRequest: true" -X POST --data "path=public/2016_public/IMG_9876.JPG" --data "shareType=3" 'https://theadamcooper.com/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares'
(This is here mostly to keep track of API request syntax.) - Request for shared items from a folder (not useful?): `curl -u "adam:password" --header "OCS-APIRequest: true" 'https://theadamcooper.com/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?path=public/2014_public&subfiles=true'` - Request for all items from a folder: ``` curl -u "adam:password" 'https://theadamcooper.com/nextcloud/remote.php/dav/files/adam/public/2015_public' -X PROPFIND --data '<?xml version="1.0" encoding="UTF-8"?> <d:propfind xmlns:d="DAV:"> <d:prop xmlns:oc="http://owncloud.org/ns"> <d:getlastmodified/> <d:getcontentlength/> <d:getcontenttype/> <oc:permissions/> <d:resourcetype/> <d:getetag/> <oc:share-types/> </d:prop> </d:propfind>' ``` - Sample response including shared and non-shared files: ``` <?xml version="1.0" encoding="UTF-8"?> <d:multistatus xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:s="http://sabredav.org/ns"> <d:response> <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/</d:href> <d:propstat> <d:prop> <d:getlastmodified>Sun, 25 Apr 2021 19:59:42 GMT</d:getlastmodified> <oc:permissions>RGDNVCK</oc:permissions> <d:resourcetype> <d:collection /> </d:resourcetype> <d:getetag>"6085ca2e0875a"</d:getetag> <oc:share-types> <oc:share-type>3</oc:share-type> </oc:share-types> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> <d:propstat> <d:prop> <d:getcontentlength /> <d:getcontenttype /> </d:prop> <d:status>HTTP/1.1 404 Not Found</d:status> </d:propstat> </d:response> <d:response> <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0912.JPG</d:href> <d:propstat> <d:prop> <d:getlastmodified>Mon, 01 Mar 2021 04:37:44 GMT</d:getlastmodified> <d:getcontentlength>2259216</d:getcontentlength> <d:getcontenttype>image/jpeg</d:getcontenttype> <oc:permissions>RGDNVW</oc:permissions> <d:resourcetype /> <d:getetag>"371dd82abd34a3d42e8bec4b4f69e150"</d:getetag> <oc:share-types> <oc:share-type>3</oc:share-type> </oc:share-types> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> <d:response> <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0913.JPG</d:href> <d:propstat> <d:prop> <d:getlastmodified>Sun, 14 Jun 2015 19:01:09 GMT</d:getlastmodified> <d:getcontentlength>2302335</d:getcontentlength> <d:getcontenttype>image/jpeg</d:getcontenttype> <oc:permissions>RGDNVW</oc:permissions> <d:resourcetype /> <d:getetag>"f4a24da1d0a0ef1c01e591860f8b0c26"</d:getetag> <oc:share-types /> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> <d:response> <d:href>/nextcloud/remote.php/dav/files/adam/public/2015_public/IMG_0914.JPG</d:href> <d:propstat> <d:prop> <d:getlastmodified>Mon, 30 Mar 2020 00:04:09 GMT</d:getlastmodified> <d:getcontentlength>2316042</d:getcontentlength> <d:getcontenttype>image/jpeg</d:getcontenttype> <oc:permissions>RGDNVW</oc:permissions> <d:resourcetype /> <d:getetag>"647dc6d6eced748effe7c6537b5b7c62"</d:getetag> <oc:share-types /> </d:prop> <d:status>HTTP/1.1 200 OK</d:status> </d:propstat> </d:response> </d:multistatus> ``` - Request to share a file/folder: ``` curl -u "adam:password" --header "OCS-APIRequest: true" -X POST --data "path=public/2016_public/IMG_9876.JPG" --data "shareType=3" 'https://theadamcooper.com/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares' ```
adam commented 2022-02-28 14:55:41 +00:00 (Migrated from git.theadamcooper.com)

There's a discrepancy between the path in the href field and the path required by the Nextcloud Shares API (see above). The solution is to use the Rust library for file paths to work with this data.

The path in the href field needs to be stripped down through the username, leaving the path the user sees, for use in the Shares API.

There's a discrepancy between the path in the `href` field and the path required by the Nextcloud Shares API (see above). The solution is to use the Rust library for file paths to work with this data. The path in the `href` field needs to be stripped down through the username, leaving the path the user sees, for use in the Shares API.
adam commented 2022-03-07 07:45:06 +00:00 (Migrated from git.theadamcooper.com)

N.B.: Development of this feature has happened with the tree traversal work; there's no separate branch for this.

N.B.: Development of this feature has happened with the tree traversal work; there's no separate branch for this.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: adam/publicise-rs#2
No description provided.