Created
August 13, 2016 06:23
-
-
Save briandeheus/fb5dd53d21f650939b34437a64a9938b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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