# Upload and get file throught tag properties

**URL:** <https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856>\
**Category:** 💻 Development\
**Tags:** dev\
**Created:** [January 10, 2020, 5:47pm UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856 "2020-01-10T17:47:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur1](https://help.nextcloud.com/letter_avatar/arthur1/32/5_5575768a8748004e209b776fc1b2916d.png) [@Arthur1](https://help.nextcloud.com/u/Arthur1)\
**Post date:** [January 10, 2020, 5:47pm UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/1 "2020-01-10T17:47:50Z")

</div>

Hello everyone,

i try to upload and load files from my Spring boot application. My idea is to add some tags to those file upload those and later using these tags return those files into my application. I now use the Sardine 5.9 to access webdev server. Its possible to do that. If yes how can achieve that?

That for your suggestions.

---

<div class="post-metadata">

**Author:** ![kesselb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kesselb/32/74519_2.png) [@kesselb](https://help.nextcloud.com/u/kesselb)\
**Post date:** [January 10, 2020, 8:47pm UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/2 "2020-01-10T20:47:28Z")

</div>

> <https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/apps/dav/lib/Connector/Sabre/TagsPlugin.php>

There seems to be a TagsPlugin for DAV and it’s available by default 🥳

PropertyName: {[http://owncloud.org/ns](http://owncloud.org/ns)}tags

> <https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/apps/dav/lib/Connector/Sabre/TagList.php>

That’s the expected format for a tag.

---

<div class="post-metadata">

**Author:** ![Arthur1](https://help.nextcloud.com/letter_avatar/arthur1/32/5_5575768a8748004e209b776fc1b2916d.png) [@Arthur1](https://help.nextcloud.com/u/Arthur1)\
**Post date:** [January 13, 2020, 6:35am UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/3 "2020-01-13T06:35:57Z")

</div>

@kesselb thank a lot for your answer. BUt how can i configure this Tagplugin in my application, so that i can get files by tags. Curently i use the library Sardine 5.9 [https://github.com/lookfirst/sardine](https://github.com/lookfirst/sardine), to get files from the nextcloud server. To return this files, i have to set the remote file path of the file in the request, now what i looking for is just to select the to return files/folders by tags name. Thank you.

---

<div class="post-metadata">

**Author:** ![kesselb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kesselb/32/74519_2.png) [@kesselb](https://help.nextcloud.com/u/kesselb)\
**Post date:** [January 13, 2020, 10:52am UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/4 "2020-01-13T10:52:25Z")

</div>

I don’t know how to set and read tags with Sardine.

Upload a file with dav

```
curl -X PUT \
  https://nextcloud.test/remote.php/dav/files/admin/test.png \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 4056372' \
  -H 'Content-Type: image/jpeg' \

```

Set tag “Wallpaper” for the uploaded file

```
curl -X PROPPATCH \
  https://nextcloud.test/remote.php/dav/files/admin/test.png \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 258' \
  -H 'Content-Type: application/xml' \
  -d '<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
    <d:set>
        <d:prop>
            <oc:tags>
                <oc:tag>Wallpapers</oc:tag>
            </oc:tags>
        </d:prop>
    </d:set>
</d:propertyupdate>'

```

Request list of files and include tags into response

```
curl -X PROPFIND \
  https://nextcloud.test/remote.php/dav/files/admin/ \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Connection: keep-alive' \
  -H 'Content-Length: 435' \
  -H 'Content-Type: application/xml' \
  -d '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
    <d:prop>
        <d:getlastmodified />
        <d:getetag />
        <d:getcontenttype />
        <d:resourcetype />
        <oc:fileid />
        <oc:permissions />
        <oc:size />
        <d:getcontentlength />
        <nc:has-preview />
        <oc:favorite />
        <oc:tags />
    </d:prop>
</d:propfind>'

```

Using a dav search request is currently not supported. That’s probably a good enhancement request for [https://github.com/nextcloud/server/](https://github.com/nextcloud/server/).

---

<div class="post-metadata">

**Author:** ![Arthur1](https://help.nextcloud.com/letter_avatar/arthur1/32/5_5575768a8748004e209b776fc1b2916d.png) [@Arthur1](https://help.nextcloud.com/u/Arthur1)\
**Post date:** [January 14, 2020, 6:24am UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/5 "2020-01-14T06:24:54Z")

</div>

@kesselb thank you very much for your help. I will try it.

---

<div class="post-metadata">

**Author:** ![kesselb](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kesselb/32/74519_2.png) [@kesselb](https://help.nextcloud.com/u/kesselb)\
**Post date:** [January 22, 2020, 9:38pm UTC](https://help.nextcloud.com/t/upload-and-get-file-throught-tag-properties/67856/6 "2020-01-22T21:38:01Z")

</div>

If you want to set the tags visible with the interface please check this [Is there a way to add tags per client API?](https://help.nextcloud.com/t/is-there-a-way-to-add-tags-per-client-api/68849).

@Arthur1 added the link for people coming via the search.
