This app allows limiting the number of downloads for external link shares.
The examples below can be run using hurl.
Tip
To ignore assertions pass the --ignore-asserts
flag.
An external share limit may be queried by its token.
hurl get.hurl --variable token='2Nyq27RKT7Jw9q3'
get.hurl
GET https://nextcloud.local/ocs/v2.php/apps/files_downloadlimit/api/v1/{{token}}/limit
OCS-APIRequest: true
Accept: application/json
[BasicAuth]
alice: alice
HTTP 200
[Asserts]
jsonpath "$.ocs.data.limit" exists
jsonpath "$.ocs.data.count" exists
hurl propfind.hurl --variable owner=admin --variable path=/welcome.txt
propfind.hurl
PROPFIND https://nextcloud.local/remote.php/dav/files/{{owner}}/{{path}}
[BasicAuth]
{{owner}}: {{owner}}
```xml
<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
<d:prop>
<oc:fileid />
<d:displayname />
<d:getlastmodified />
<d:getcontenttype />
<oc:size />
<oc:owner-id />
<oc:share-types />
<nc:sharees />
<nc:share-download-limits />
</d:prop>
</d:propfind>
```
HTTP 207
[Asserts]
xpath "//nc:share-download-limits" isCollection
hurl set.hurl --variable token='2Nyq27RKT7Jw9q3' --variable limit=5
set.hurl
PUT https://nextcloud.local/ocs/v2.php/apps/files_downloadlimit/api/v1/{{token}}/limit
OCS-APIRequest: true
Accept: application/json
[BasicAuth]
alice: alice
{
"limit": {{limit}}
}
HTTP 200
[Asserts]
jsonpath "$.ocs.data" isEmpty
hurl remove.hurl --variable token='2Nyq27RKT7Jw9q3'
remove.hurl
DELETE https://nextcloud.local/ocs/v2.php/apps/files_downloadlimit/api/v1/{{token}}/limit
OCS-APIRequest: true
Accept: application/json
[BasicAuth]
alice: alice
HTTP 200
[Asserts]
jsonpath "$.ocs.data" isEmpty
Admins may set a default limit.
hurl set-default.hurl --variable limit=1
set-default.hurl
PUT https://nextcloud.local/ocs/v2.php/apps/files_downloadlimit/api/v1/limit
OCS-APIRequest: true
Accept: application/json
[BasicAuth]
admin: admin
{
"limit": {{limit}}
}
HTTP 200
[Asserts]
jsonpath "$.ocs.data" isEmpty