Skip to content

Instantly share code, notes, and snippets.

@olivx
Last active November 16, 2018 18:18
Show Gist options
  • Save olivx/ff7500f23525c3bb42c02a6dfd5b7d08 to your computer and use it in GitHub Desktop.
Save olivx/ff7500f23525c3bb42c02a6dfd5b7d08 to your computer and use it in GitHub Desktop.
fazendo o upload para file sytem suando o boto3 ou file system stora
import boto3
from boto.s3.connection import Bucket, Key
video_id = request.POST.get('vid_id')
video_name = video_id + "_qvga_webm.webm"
video_interview = request.FILES['video_interview']
uploaded_file_url = "https://s3.amazonaws.com/yourbubeckt/"
filename = 'pass-your-path/' + video_name
session = boto3.session.Session(
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY
)
s3 = session.resource('s3')
s3.Bucket('yourbubeckt').put_object(Key=filename, Body=video_interview)
# for public object pass ACL='public-read'
# s3.Bucket('yourbubeckt').put_object(Key=filename, Body=video_interview, ACL='public-read')
from django.core.files.storage import FileSystemStorage
video_id = request.POST.get('vid_id')
video_name = video_id + "_qvga_webm.webm"
video_interview = request.FILES['video_interview']
fs = FileSystemStorage()
filename = fs.save(video_name, video_interview)
uploaded_file_url = fs.url(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment