Transferring images requires special attention since they have to send a lot of data. Therefore they also are a bit different than advertised in the Flickr API documentation.
The flickr.upload(...) method has the following parameters:
Space-delimited list of tags. Tags that contain spaces need to be quoted. For example:
tags='''Amsterdam "central station"'''
Those are two tags, “Amsterdam” and “central station”.
The fileobj parameter can be used to monitor progress via a callback method. For example:
import os.path
class FileWithCallback(object):
def __init__(self, filename, callback):
self.file = open(filename, 'rb')
self.callback = callback
# the following attributes and methods are required
self.len = os.path.getsize(filename)
self.fileno = self.file.fileno
self.tell = self.file.tell
def read(self, size):
if self.callback:
self.callback(self.tell() * 100 // self.len)
return self.file.read(size)
params['fileobj'] = FileWithCallback(params['filename'], callback)
rsp = flickr.upload(params)
The callback method takes one parameter:
def callback(progress):
print(progress)
progress is a number between 0 and 100.
The flickr.replace(...) method has the following parameters:
Only the image itself is replaced, not the other data (title, tags, comments, etc.).