-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuploadfiletoheroku.py
33 lines (28 loc) · 1.01 KB
/
uploadfiletoheroku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# from django.http import HttpResponse, JsonResponse
import requests
import cloudinary
import cloudinary.uploader
cloudinary.config(
cloud_name = 'detxlswii',
api_key = '474368939111198',
api_secret = 'gAmfegRLeJKZC66RWtNlW0Pp6tM'
)
def uploadvideotoheroku(filepath,YTtitle):
try:
print(filepath)
filepath = str(filepath)
# filepath = filepath.replace(' ','\ ')
filepath="final.mp4"
print(filepath)
myurl = 'http://ytserver.eu-gb.cf.appdomain.cloud/news/savevideo/'
upload_data = cloudinary.uploader.upload_large(filepath)
videoPublicId=str(upload_data['public_id'])
videoUrl=str(upload_data['secure_url'])
print(videoPublicId)
print(videoUrl)
title=YTtitle
getdata = requests.post(myurl,data={'title':title,'videoPublicId':videoPublicId,'videoUrl':videoUrl})
print(getdata.text)
# r=requests.post('http://lit-sierra-15246.herokuapp.com/videoupload/')
except Exception as e:
print(e)