share link fixed
This commit is contained in:
parent
b9994e6a45
commit
be32b3f63e
@ -46,7 +46,7 @@ def import_all(monitor):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_share_link(recipe):
|
def create_share_link(recipe):
|
||||||
url = "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"
|
url = "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@ -59,4 +59,27 @@ def get_share_link(recipe):
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = requests.post(url, headers=headers, data=json.dumps(data))
|
r = requests.post(url, headers=headers, data=json.dumps(data))
|
||||||
|
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
def get_share_link(recipe):
|
||||||
|
url = "https://api.dropboxapi.com/2/sharing/list_shared_links"
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Authorization": "Bearer " + recipe.storage.token,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"path": recipe.file_uid
|
||||||
|
}
|
||||||
|
|
||||||
|
r = requests.post(url, headers=headers, data=json.dumps(data))
|
||||||
|
p = r.json()
|
||||||
|
|
||||||
|
for l in p['links']:
|
||||||
|
return l['url']
|
||||||
|
|
||||||
|
response = create_share_link(recipe)
|
||||||
|
return response['url']
|
||||||
|
@ -14,8 +14,7 @@ def get_file_link(request, recipe_id):
|
|||||||
|
|
||||||
if recipe.storage.method == Storage.DROPBOX:
|
if recipe.storage.method == Storage.DROPBOX:
|
||||||
if recipe.link == "":
|
if recipe.link == "":
|
||||||
response = dropbox.get_share_link(recipe) # TODO response validation
|
recipe.link = dropbox.get_share_link(recipe) # TODO response validation
|
||||||
recipe.link = response['url']
|
|
||||||
recipe.save()
|
recipe.save()
|
||||||
|
|
||||||
return HttpResponse(recipe.link)
|
return HttpResponse(recipe.link)
|
||||||
|
@ -40,7 +40,7 @@ def sync_wait(request):
|
|||||||
def batch_import(request):
|
def batch_import(request):
|
||||||
imports = RecipeImport.objects.all()
|
imports = RecipeImport.objects.all()
|
||||||
for new_recipe in imports:
|
for new_recipe in imports:
|
||||||
recipe = Recipe(name=new_recipe.name, file_path=new_recipe.path, storage=new_recipe.storage, file_uid=new_recipe.file_uid)
|
recipe = Recipe(name=new_recipe.name, file_path=new_recipe.file_path, storage=new_recipe.storage, file_uid=new_recipe.file_uid)
|
||||||
recipe.save()
|
recipe.save()
|
||||||
new_recipe.delete()
|
new_recipe.delete()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user