Need to see if your shared folder is taking up space on your dropbox đšâđ»? Find out how to check here.
Forum Discussion
mark2mark
8 years agoHelpful | Level 7
multiple calls of `files_get_temporary_link`
Hello, I just got stuck when trying to call dbx.files_get_temporary_link(path) multiple times in python. because I need to create a bunch of links for a dynamically fed input (different paths...
- 8 years ago
Well, if you uncomment the second call, and hence have both ones running, it doesnât work anymore at my side. With the exact code I posted before.
Is that what you also tried, too? You said »both calls, each generating a unique link to the same file.« but it should be two different files. Just saying.
Now that I wanted to create a simplified version of the code for you, this one actually works. It is very weird though, because it ainât too different from my actual code. Iâll post the now working one here (maybe also as a refernece for others). But I still donât understand why my other code doesnât work.#!/usr/bin/env python # -*- coding: utf-8 -*- import dropbox import os import traceback access_token = '*****' dbx = dropbox.Dropbox(access_token) def getTemporaryLink(dbx, folder, name): path = '/%s/%s' % (folder, name) try: link = dbx.files_get_temporary_link(path) except dropbox.exceptions.HttpError as err: print '*** HTTP error', err return None return link products = ["One.zip", "Two.zip"] temporaryLinks = [] for product in products: x = getTemporaryLink(dbx, "myFolder", product) temporaryLinks.append(x) for linkResult in temporaryLinks: print linkResult.link
mark2mark
8 years agoHelpful | Level 7
Wow chirstius, what a quick reply. Thank you!
hereâs a basic code.
Thanks in advance!
#!/usr/bin/env python # -*- coding: utf-8 -*- import dropbox import os access_token = "*****" dbx = dropbox.Dropbox(access_token) def getTemporaryLink(dbx, folder, name): path = '/%s/%s' % (folder, name) try: link = dbx.files_get_temporary_link(path) except dropbox.exceptions.HttpError as err: print '*** HTTP error', err return None return link folder = "myFirstLevelFolder" temporaryLink1 = getTemporaryLink(dbx, folder, "thing1.zip") print temporaryLink1 # WORKS up to here.
# temporaryLink2 = getTemporaryLink(dbx, folder, "thing2.zip") # breaks, throws error # print temporaryLink2
chirstius
Dropbox Staff
8 years agoThanks for posting. I was able to run your code and it seems to work without error - both calls, each generating a unique link to the same file.
The error you are seeing would seem to imply trying to invoke a method call directly on the results object (or a property of it). This code isn't doing anything beyond printing the results. Can you show some of the original code as-is and let's see if we can figure out what might be going wrong there?
Thanks!
-Chuck
- mark2mark8 years agoHelpful | Level 7
Well, if you uncomment the second call, and hence have both ones running, it doesnât work anymore at my side. With the exact code I posted before.
Is that what you also tried, too? You said »both calls, each generating a unique link to the same file.« but it should be two different files. Just saying.
Now that I wanted to create a simplified version of the code for you, this one actually works. It is very weird though, because it ainât too different from my actual code. Iâll post the now working one here (maybe also as a refernece for others). But I still donât understand why my other code doesnât work.#!/usr/bin/env python # -*- coding: utf-8 -*- import dropbox import os import traceback access_token = '*****' dbx = dropbox.Dropbox(access_token) def getTemporaryLink(dbx, folder, name): path = '/%s/%s' % (folder, name) try: link = dbx.files_get_temporary_link(path) except dropbox.exceptions.HttpError as err: print '*** HTTP error', err return None return link products = ["One.zip", "Two.zip"] temporaryLinks = [] for product in products: x = getTemporaryLink(dbx, "myFolder", product) temporaryLinks.append(x) for linkResult in temporaryLinks: print linkResult.link
- chirstius8 years ago
Dropbox Staff
I tried it both ways - same file, and two different files. Both seemed to work without issue. Either way, I'm glad you've got it working now. Thanks for sharing the code hopefully someone else might find it valuable.
Good luck with the rest of the project!
-Chuck
- mark2mark8 years agoHelpful | Level 7
I appologize that I might have made some mistake somwhere. I really tried several times, different things. Well, anyway, Iâm also glad.
PS: The API is really good. Thank you for it and also for the incredibly fast feedback! :)
- aesanne8 years agoNew member | Level 2
I have an error regarding files_get_temporary_link, how to trouble shooting this?
dropbox.exceptions.ApiError: ApiError('4d0b8810a976a3c06b9f77f38464199c', GetTemporaryLinkError(u'path', LookupError(u'not_found', None)))
- Greg-DB8 years ago
Dropbox Community Moderator
aesanne You can find information on each of the errors in the documentation here.
The 'not_found' error means "There is nothing at the given path". You should check the 'path' value you're supplying to the call to make sure you're supplying a valid one.
One good way to check what is in the account is to call files_list_folder with path="". That will list the contents of the root that your app has access to. (I.e., the root of the Dropbox account, for full Dropbox apps, or the root of the app folder, for app folder apps.)
Anyway, this seems to be a different problem than what this thread was for, so if you're still having trouble, please open a new thread with more details so we don't spam the other people on this thread.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!