Skip to content

Instantly share code, notes, and snippets.

@deserat
Created September 17, 2013 23:20
Show Gist options
  • Save deserat/6602053 to your computer and use it in GitHub Desktop.
Save deserat/6602053 to your computer and use it in GitHub Desktop.
api example of posting a file. The content file object is part of django but it's easily separated if you use python. Just copy that class out https://github.com/django/django/blob/master/django/core/files/base.py#L132
from django.core.files.base import ContentFile
f = ContentFile(o.read(), name='pic.png')
response = signed_post(self.api_client, self.c, '/api/v1/user/register/', {
'social_id': 'twitter:123452',
'gender': 'f',
'email': 'blah@blah.com',
'name': 'whatevs',
'location': 'New York',
'dob': '2000-01-11',
'country': 'USA',
'pic': f,
})
o.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment