I am new at VK api
.
I want to upload video via the VK API. I cannot get sample codes in my investigation in google.
Can anyone give me sample code.
I am new at VK api
.
I want to upload video via the VK API. I cannot get sample codes in my investigation in google.
Can anyone give me sample code.
First you need to get http-url to upload video using this API method.
Then you should make a POST-request containing field with "video_file" which will contain your video file in binary mode. Then you should call video.save method to save changes and get video_id
Using requests library:
import requests
with open('upload_file_name', 'rb') as f:
# use upload url you get from vk via 'video.save' call
resp = requests.post(vk_upload_url, files={'video_file': f})
# dumb response check
if resp.json().get('size'):
print('upload OK')
else:
print('shit happens!')
You can read about details in vk.api docs