EnterpriseyIntranet / nextcloud-API

NextCloud OCS API for Python
GNU General Public License v3.0
27 stars 27 forks source link

Question: how to check checksum of a file? #47

Closed jlegido closed 4 years ago

jlegido commented 4 years ago

First of all many thanks for your time.

Looks like Nextcloud supports reading checksum of a file.

Performing a quick search, I found this line but I have no idea how to use it.

I did a "nxc.get_shares().data", but any of the shares contains any key with checksum.

Could somebody please provide an example, if it's implemented, about how to check the cheksum of a file?

Thanks.

jlegido commented 4 years ago

I will answer myself with a snippet of code:

import sys
import os
from os.path import dirname
from os.path import join

sys.path.insert(0, '/home/usuario/git/nextcloud-API/src')

from nextcloud import NextCloud

NEXTCLOUD_URL = 'https://example.com'
NEXTCLOUD_USERNAME = 'user'
NEXTCLOUD_PASSWORD = 'password'
UID = '12345678-9716-1039-815a-6d34df58f701'

to_js = True

nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=to_js)

o = nxc.list_folders(UID, depth=1, all_properties=True)
o.data

Result similar to:

...
 {'href': '/remote.php/dav/files/12345678-9716-1039-815a-6d34df58f701/foo/file1',
  'last_modified': 'Tue, 03 Dec 2019 16:35:59 GMT',
  'etag': '"2556560157ac479e84eb8815cc1c4e06"',
  'content_type': 'application/pdf',
  'resource_type': None,
  'file_id': '3458',
  'size': '110725',
  'content_length': '110725',
  'has_preview': 'false',
  'favorite': '0',
  'comments_unread': '0',
  'owner_display_name': 'whatever',
  'share_types': None}]

So the checksum is 'etag' key

matejak commented 4 years ago

Great finding, thank you!

maks2199 commented 3 months ago

It doesn't seems that etag is a checksum (using 29.0 NC verson).