Skip to content

Add expiration date support for shared links #287

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions owncloud/owncloud.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might suggest snake casing the two words expire_date as they are camel cased in the official API:

https://doc.owncloud.com/server/next/developer_manual/core/apis/ocs-share-api.html#create-a-new-share

Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ def share_file_with_link(self, path, **kwargs):
defaults to read only (1)
:param public_upload (optional): allows users to upload files or folders
:param password (optional): sets a password
:param expiredate (optional): sets an expiration date for the shared link
https://doc.owncloud.com/server/next/admin_manual/configuration/files/file_sharing_configuration.html
:param name (optional): display name for the link
:returns: instance of :class:`ShareInfo` with the share info
Expand All @@ -877,6 +878,7 @@ def share_file_with_link(self, path, **kwargs):
perms = kwargs.get('perms', None)
public_upload = kwargs.get('public_upload', 'false')
password = kwargs.get('password', None)
expiredate = kwargs.get('expiredate', None)
name = kwargs.get('name', None)

path = self._normalize_path(path)
Expand All @@ -888,6 +890,8 @@ def share_file_with_link(self, path, **kwargs):
post_data['publicUpload'] = str(public_upload).lower()
if isinstance(password, six.string_types):
post_data['password'] = password
if isinstance(expiredate, datetime.date):
post_data['expireDate'] = expiredate
if name is not None:
post_data['name'] = self._encode_string(name)
if perms:
Expand Down