Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am not able to run Content-Type:application/octet-stream On linkedin Multiprt video Upload #188

Open
yadavpravesh26 opened this issue Jul 6, 2023 · 0 comments

Comments

@yadavpravesh26
Copy link

yadavpravesh26 commented Jul 6, 2023

Below is mu code when i run it i am not gettinging "Etage" like this:

HTTP/1.1 200 OK
Content-Length: 0
Connection: keep-alive
x-amz-id-2: 2wer1EizXFXQneT6n1VAa4l1ggPOM9cOl0jJFgpk0ocOYyZsjLKAHaQwmOKi47hHG6D9R2w4y5A=
x-amz-request-id: C6DA7DF813E33C69
Date: Thu, 27 Sep 2018 22:40:01 GMT
x-amz-version-id: AguPSmqVmxmrKvuJ56mIDeUu5FqnJffZ
x-amz-server-side-encryption: aws:kms
x-amz-server-side-encryption-aws-kms-key-id: arn:aws:kms:us-east-1:123456789:key/e10ace24-blah-4977-bar-89foo193e2ab
ETag: "e4383924336106965d6cd2a111beaceb"
Server: AmazonS3
X-Amz-Cf-Id: CgvELDhzYQgJ8qpJka_pAscHJ4Dnwsc0sDj4zZAiwnji-YZXK2aRdA==

Here is Documentation of API:
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/vector-asset-api?view=li-lms-2023-06&tabs=http#registering-multi-part-upload

`
import requests
import json
import urllib.request

video_url = input_data["file_path"] #VIDEO URL
upload_instructions = json.loads(input_data["upload_instructions"]) #GET Upload URL and other rquire thing

def upload_video_chunk_data(url, file_chunk):
headers = {"Content-Type": "application/octet-stream"}
response = requests.post(url, headers=headers, data=file_chunk)
print(response)

global file_chunk
global upload_url

Iterate over upload instructions and upload video chunks

for upload_instruction in upload_instructions["value"]["uploadInstructions"]:
upload_url = upload_instruction["uploadUrl"]
first_byte = upload_instruction["firstByte"]
last_byte = upload_instruction["lastByte"]

# Open the video file and seek to the specified byte range
with urllib.request.urlopen(video_url) as file:
    file_chunk = file.read(last_byte - first_byte + 1)
    
# Upload the video chunk to the specified URL
upload_video_chunk_data(upload_url, file_chunk)

Send a POST request to finalize the video upload

videoID = upload_instructions['value']['video']
return {"video_id":videoID}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant