Skip to content

Instantly share code, notes, and snippets.

@nulpunkt
Last active October 10, 2019 09:32
Show Gist options
  • Save nulpunkt/ab1e139315867668d6e1256083307ecf to your computer and use it in GitHub Desktop.
Save nulpunkt/ab1e139315867668d6e1256083307ecf to your computer and use it in GitHub Desktop.
Upload a file to Skyfish via the API
import requests
import json
import sys
import time
import os
if len(sys.argv) < 3:
raise Exception("Usage: python throw-into-skyfish.py <folder_id> <file_path>")
auth = {'Authorization': 'CBX-SIMPLE-TOKEN Token=TOKENGOESHERE'}
register = requests.post('https://api.colourbox.com/upload/register', data=json.dumps({'folder': int(sys.argv[1])}), headers=auth).json()
fields = {}
for field in register['fields']:
if field['name'] != 'file':
fields[field['name']] = field['value']
media_upload = requests.post(register['action'], files={'file': open(sys.argv[2], 'rb')}, data=fields).json()
media = requests.get('https://api.colourbox.com/media/' + str(media_upload['media_id']), headers=auth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment