amazon web services - using file stored on aws s3 storage -- media storage as input of a process in django view -
i trying make django app in production in aws, used elastic beanstalk deploy ec2 instance created , connected rds database mysql instance , use bucket in amazon s3 storage store media files on it.
when user upload video, stored in s3 : "https://bucketname.s3.amazonaws.com/media/videos/videoname.mp4". in django developpement mode, using video filename input batch script gives video output.
my view in developpement mode follow:
def get(request): # video var = video.objects.order_by('id').last() v = '/home/myproject/media/videos/' + str(var) # call process subprocess.call("./step1.sh %s" % (str(v)), shell=true) return render(request, 'endexecut.html')
in production mode in aws (problem), tried:
v = 'https://bucketname.s3.amazonaws.com/media/videos/' + str(var)
but batch process doesn't accept url input process.
how can use video file s3 bucket process in view described ? thank in advance.
you should not hard-code string. there couple of things wrong that:
"bucketname" not name of bucket. should use name of bucket if @ work.
your media file url (in
settings.py
) should pointing bucket url files saved (if it's configured). can make use of:video_path = settings.media_url + video_name
i assuming using s3boto handle storages (that's not prerequisite though, makes storage handling smarter , it's highly recommended if pushing s3 django app)
Comments
Post a Comment