Skip to content

Instantly share code, notes, and snippets.

@Kuranes
Forked from sbouafif/sketchfab-api.py
Last active December 14, 2015 06:49
Show Gist options
  • Save Kuranes/5046175 to your computer and use it in GitHub Desktop.
Save Kuranes/5046175 to your computer and use it in GitHub Desktop.
# easy_install poster
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
# Register the streaming http handlers with urllib2
register_openers()
path="./"
filename="model.dae"
description="Test of the api with a simple model"
token_api="ff00ff"
title="Uber Glasses"
tags="test collada glasses"
private=1
password=""
import json
import base64
import urllib2
url="https://api.sketchfab.com/v1/models"
data = {
'title': title,
'description': description,
'fileModel': open(path+filename, 'rb'),
'filenameModel': filename,
'tags': tags,
'token': token_api,
'private': private,
'password': password
}
datamulti, headers = multipart_encode(data)
request = urllib2.Request(url, datamulti, headers, None, True)
print urllib2.urlopen(request).read()
@Kuranes
Copy link
Author

Kuranes commented Feb 27, 2013

Updated in order to allow uploads on win32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment