[Answered ]-Upload an image to twitter via tweepy from django form

1👍

Method update_with_media() has only one positional argument which takes filename.
So you can specify filename something like this:

api.update_with_media(request.FILES['file'].name,
                      status="Hello first image")

Also you should pass file using keyword argument ‘file’:

api.update_with_media(request.FILES['file'].name,
                      file=request.FILES['file'], 
                      status="Hello first image")

1👍

As per docs, you have to pass both file parameter which will be opened internally and filename parameter which is needed to determine MIME type and will be used to as form field in post data. So just pass them explicitly as keyword arguments and you should be fine.

Leave a comment