cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

multiple calls of `files_get_temporary_link`

multiple calls of `files_get_temporary_link`

mark2mark
Helpful | Level 7
Go to solution

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)

Actually one call works, and as soon as I add one more, i get the Error:

TypeError: 'GetTemporaryLinkResult' object is not callable

 

I cannot find anything in the documentation that points to this issue. I see no reason why it ain’t working.
Help would be very much appreciated.

1 Accepted Solution

Accepted Solutions

mark2mark
Helpful | Level 7
Go to solution

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

 

View solution in original post

13 Replies 13

chirstius
Dropbox Staff
Go to solution

Hey mark2mark,

 

From the sample you have provided, you are correct, there's nothing technically wrong with the call to get_temporary_link(), but the issue seems to revolve around what is being done to the result that comes back (a GetTemporaryLinkResult object).

 

Would you be willing to post a bit more of your code to help identify what might be causing this? Particularly what's being done with the result of the call.

 

Thanks!

 

-Chuck

mark2mark
Helpful | Level 7
Go to solution

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
Go to solution

Thanks 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

mark2mark
Helpful | Level 7
Go to solution

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

 

chirstius
Dropbox Staff
Go to solution

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

mark2mark
Helpful | Level 7
Go to solution

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! 🙂

mark2mark
Helpful | Level 7
Go to solution

Ahem, do you know where my post is gone to?

I made one answer with a working code and the iteration calls. I don’t see it here in the tread anymore. Someone must have removed it. What happened?

Greg-DB
Dropbox Staff
Go to solution

@mark2mark The forum flagged your post as spam for some reason. I restored it. Thanks!

mark2mark
Helpful | Level 7
Go to solution

Thank you! 😄

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    aesanne New member | Level 2
  • User avatar
    mark2mark Helpful | Level 7
  • User avatar
    Vij New member | Level 2
What do Dropbox user levels mean?