owncloud / pyocclient

ownCloud client library for Python
MIT License
294 stars 114 forks source link

Sharing a directory #218

Open steve500002 opened 6 years ago

steve500002 commented 6 years ago

When attempting to share a directory: share_link = oc.share_file_with_link(directory)

I get 'id': data_el.find('id').text, AttributeError: 'NoneType' object has no attribute 'text'

I know that the function explicitly talks about files, but documentation says I can share directories and there is not a share_directory_with_link function so I am working on basis that this function should work.

Error refers to line 833 - data=post_data

and post data is created on 818 post_data = { 'shareType': self.OCS_SHARE_TYPE_LINK, 'path': self._encode_string(path), }

Any ideas?

kevdevg commented 6 years ago

same problem, any progress on this?

PVince81 commented 5 years ago

it should work with directories as well and I believe some of the unit tests also do so.

please specify what OC version you are using and also check owncloud.log for server side errors

PVince81 commented 5 years ago

someone reported the same error when sharing files: https://github.com/owncloud/pyocclient/issues/214

so this is not related to sharing folders but sharing in general, please verify the server env for errors

bbs-web commented 4 years ago

First of all: I am using nextcloud 16.05 on a ubuntu/snap installation.

After I done . a little digging into the problem I found out that the AttributeError: 'NoneType' object has no attribute 'text' pops up because the response doesn't have the expected format. In fact the response returns a list of shares.

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message>OK</message>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data>
  <element>
   <id>70</id>
   <share_type>1</share_type>
   <uid_owner>admin</uid_owner>
   <displayname_owner>admin</displayname_owner>
   <permissions>31</permissions>
   <stime>1569585670</stime>
   <parent/>
   <expiration/>
   <token/>
   <uid_file_owner>admin</uid_file_owner>
   <note></note>
   <label/>
   <displayname_file_owner>admin</displayname_file_owner>
   <path>/3D Projects/04 Rigging</path>
   <item_type>folder</item_type>
   <mimetype>httpd/unix-directory</mimetype>
   <storage_id>home::admin</storage_id>
   <storage>2</storage>
   <item_source>761</item_source>
   <file_source>761</file_source>
   <file_parent>821</file_parent>
   <file_target>/04 Rigging</file_target>
   <share_with>Rigging</share_with>
   <share_with_displayname>Rigging</share_with_displayname>
   <mail_send>0</mail_send>
   <hide_download>0</hide_download>
  </element>
 ...etc

I checked the Nextcloud API and the request format seemed to be ok. I can't get to the bottom of this, but hopefully the information above might help someone else get to it.

feelwhy commented 4 years ago

Have faced the same issue. For my particular purposes (need only the URL of share), it is enough to slightly adapt the method share_file_with_link. In particular, replace the part: 'name': data_el.find('name').text Name does not exist in data. At least in how NextCloud returns that

PVince81 commented 4 years ago

Ah, it is possible that Nextcloud did not implement giving names to public links.

A fix would be to add an if condition there to check if that attribute is set or not, and ignore if it's not.

PVince81 commented 4 years ago

it seems the original report was about the id field, which I believe should exist in both OC and NC.

the proposed fix could be applied to both fields, just in case

sergey-sc commented 4 years ago

hi still no solution?

kobuki commented 3 years ago

Seeing the exact same error with pyocclient 0.6, Nextcloud 19.0.1.

sergey-sc commented 3 years ago

I have solved this issue within installing version 0.4 of pyocclient pip3 install pyocclient==0.4 Works without any errors

kobuki commented 3 years ago

@sergey-sc: Thanks, your workaround is working.

drxzcl commented 3 years ago

I ran into other problems while downgrading, so I implemented a basic fix instead.

luffah commented 3 years ago

Similar bugs #218, #259. #263 (with a simple fix proposal - a mere workaround)

victorterancas commented 2 years ago

Hi. I face the same problem as the topic. I see there is a commit, but the library i install (the last one) does not have that changes in it. Could you redo the commit?

whateverforever commented 3 weeks ago

having same issue with pyocclient==0.6 and nextcloud==28.0.8

dbartenstein commented 3 weeks ago

having same issue with pyocclient==0.6 and nextcloud==28.0.8

Same here.