Skip to content

Instantly share code, notes, and snippets.

@briandeheus
Created August 13, 2016 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandeheus/fb5dd53d21f650939b34437a64a9938b to your computer and use it in GitHub Desktop.
Save briandeheus/fb5dd53d21f650939b34437a64a9938b to your computer and use it in GitHub Desktop.
# upload.py
from api.api import BaseAPI
class API(BaseAPI):
def execute(request, params)
ModelName.upload_from_url(request.user, params.get('url'))
# models.py
from django.db imports models
import requests
import logging
logger = logging.getLogger(__file__)
class ModelName(models.Model):
@staticmethod
def upload_from_url(owner, url):
with file(tmp_name, 'w+') as tmp_file:
response = requests.get(url, stream=True)
logger.info('Beginning downloading %s' % url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment