Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WP#48988]Write Document for getting file information from file id #486

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,109 @@ bash integration_setup.sh

> Note: these credentials are only used by the script to do the setup. They are not stored/remembered.

## Get file information
We have two endpoints `fileinfo` and `filesinfo` from which we can get the information of a single or multiple files.
SagarGi marked this conversation as resolved.
Show resolved Hide resolved

SagarGi marked this conversation as resolved.
Show resolved Hide resolved
### Requirements
This endpoint has a soft dependency on Nextcloud's [Activity](https://github.com/nextcloud/activity) app. In the absence of the Activity app the response fields like `modifier_name` , `modifier_id` will be returned as null. So, it is encouraged to have Activity app installed and enabled.

1. **Get information of single file**:
Send the `GET` request to `fileinfo` endpoint with `FILE_ID` of the file to retrieve information.

```bash
curl -H "Accept: application/json" -H "OCS-APIRequest: true" -u USER:PASSWD http://<nextcloud_host>/ocs/v1.php/apps/integration_openproject/fileinfo/<FILE_ID>

```
Upon success the response from the above curl request will be
```json
{
"ocs": {
"meta": {
"status": "ok",
"statuscode": 100,
"message": "OK",
"totalitems": <totalitems>,
"itemsperpage": <itemsperpage>
},
"data": {
"status": "OK",
"statuscode": 200,
"id": <FILE_ID>,
"name": <file_name>,
"mtime": <mtime>,
"ctime": <ctime>,
"mimetype": <mimetype>,
"size": <size>,
"owner_name": <owner_name>,
"owner_id": <owner_id>,
"trashed": <boolean>,
"modifier_name": <modifier_name>,
"modifier_id": <modifier_id>,
"dav_permissions": <dav_permissions>,
"path": <path>
}
}
}
```
2. **Get information of multiple files**:
Send the `POST` request to `filesinfo` endpoint with data `fileIds` of the files to retrieve information.
SagarGi marked this conversation as resolved.
Show resolved Hide resolved

```bash
curl -H "Accept: application/json" -H "Content-Type:application/json" -H "OCS-APIRequest: true" -u USER:PASSWD http://<nextcloud_host>/ocs/v1.php/apps/integration_openproject/filesinfo -X POST -d '{"fileIds":[<FILE_ID1>, <FILE_ID2> ,...]}'

```
Upon success the response from the above curl request will be
```json
{
"ocs": {
"meta": {
"status": "ok",
"statuscode": 100,
"message": "OK",
"totalitems": <totalitems>,
"itemsperpage": <itemsperpage>
},
"data": {
<FILE_ID1>: {
"status": "OK",
"statuscode": 200,
"id": <FILE_ID1>,
"name": <file_name>,
"mtime": <mtime>,
"ctime": <ctime>,
"mimetype": <mimetype>,
"size": <size>,
"owner_name": <owner_name>,
"owner_id": <owner_id>,
"trashed": <boolean>,
"modifier_name": <modifier_name>,
"modifier_id": <modifier_id>,
"dav_permissions": <dav_permissions>,
"path": <path>
},
<FILE_ID2>: {
"status": "OK",
"statuscode": 200,
"id": <FILE_ID1>,
"name": <file_name>,
"mtime": <mtime>,
"ctime": <ctime>,
"mimetype": <mimetype>,
"size": <size>,
"owner_name": <owner_name>,
"owner_id": <owner_id>,
"trashed": <boolean>,
"modifier_name": <modifier_name>,
"modifier_id": <modifier_id>,
"dav_permissions": <dav_permissions>,
"path": <path>
},
...
}
}
}
```

## Direct upload
There's an end-point `direct-upload` available which can be used for direct-upload. There's two steps to direct upload. First we need to get the `token`. Then use the token in the direct upload request.

Expand Down
Loading