本文整理汇总了Python中dropbox.Dropbox.sharing_create_shared_link_with_settings方法的典型用法代码示例。如果您正苦于以下问题:Python Dropbox.sharing_create_shared_link_with_settings方法的具体用法?Python Dropbox.sharing_create_shared_link_with_settings怎么用?Python Dropbox.sharing_create_shared_link_with_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dropbox.Dropbox
的用法示例。
在下文中一共展示了Dropbox.sharing_create_shared_link_with_settings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload
# 需要导入模块: from dropbox import Dropbox [as 别名]
# 或者: from dropbox.Dropbox import sharing_create_shared_link_with_settings [as 别名]
def upload(dropbox_helper_id, access_token, size, max_retries):
from .models import DropboxUploadHelper
helper = DropboxUploadHelper.objects.get(id=dropbox_helper_id)
def progress_callback(bytes_uploaded, helper=helper, size=size):
helper.progress = float(bytes_uploaded) / size
helper.save()
try:
dropbox_path = '/{}'.format(os.path.basename(helper.src))
path_display = upload_to_dropbox(access_token, dropbox_path, helper.src, progress_callback)
except Exception as e:
helper.failure_reason = str(e)
helper.save()
couch_user = CouchUser.get_by_username(helper.user.username)
if helper.failure_reason is None:
dbx = Dropbox(access_token)
path_link_metadata = dbx.sharing_create_shared_link_with_settings(
path_display,
SharedLinkSettings(
requested_visibility=RequestedVisibility.team_only,
),
)
context = {
'share_url': path_link_metadata.url,
'path': os.path.join(
'Apps',
settings.DROPBOX_APP_NAME,
path_link_metadata.name,
)
}
with localize(couch_user.get_language_code()):
subject = _('{} has been uploaded to dropbox!'.format(helper.dest))
html_content = render_to_string('dropbox/emails/upload_success.html', context)
text_content = render_to_string('dropbox/emails/upload_success.txt', context)
else:
context = {
'reason': helper.failure_reason,
'path': helper.dest
}
with localize(couch_user.get_language_code()):
subject = _('{} has failed to upload to dropbox'.format(helper.dest))
html_content = render_to_string('dropbox/emails/upload_error.html', context)
text_content = render_to_string('dropbox/emails/upload_error.txt', context)
send_HTML_email(
subject,
helper.user.email,
html_content,
text_content=text_content,
)