MicrosoftDocs / feedback

đŸ“¢ docs.microsoft.com site feedback
https://learn.microsoft.com
Creative Commons Attribution 4.0 International
239 stars 160 forks source link

Linkedin Videos Beta Api failed to process video upload by chunk. #3793

Open osain-az opened 2 years ago

osain-az commented 2 years ago

Hello. I am using the videos beta api to upload videos to LinkedIn. which is implemented using rust.

Currently uploading video less than 4Mb works fine but when uploading file that is chunked, the uploading process was success when chunking the status it stated that the process of the video fails.

Chunking method

To chunk the file, fs::File is used which extracts as bytes Vec<u8>. This is done for either a small file or a large file.

// for video less than 4Mb
    pub fn extract_to_end(self) -> Vec<u8> {
        let mut buffer = vec![];
        let mut file = self.file;
        file.read_to_end(&mut buffer);
        buffer
    }
//For large videos use inside of a loop. 
  pub fn extract_by_size_and_offset(mut self, end_position: u64, start_position: u64) -> Vec<u8> {

        let mut file = self.file;
        //file.read_exact_at(buffer, )
        let chunk_limit = chunk_size + start_position;  
            let chunk_size = (end_position - start_position) as usize;

            let mut buffer = Vec::with_capacity(chunk_size);
            file.seek(SeekFrom::Start(start_position)).unwrap();
            file.take(chunk_size as u64)
                .read_to_end(&mut buffer)
                .unwrap();
            buffer
        } 

Making the request

       let req = match method {
            Method::GET => Client::new().get(url),
            Method::POST => Client::new().post(url),
            Method::PUT => Client::new().put(url),
            m @ _ => return Err(ClientErr::HttpClient(format!("invalid method {}", m))),
        };

        let resp = if method == Method::PUT {
// when chunking video 
            req.header("Content-Type","application/octet-stream" )
                .header("Authorization", bear_token)
                .body(Body::from(body.to_vec()))
                .send()
                .await
                .map_err(|e| ClientErr::HttpClient(format!("{:?}", e)))?
        } else {
        // small video size 
            req.header("Authorization", bear_token)
                .body(Body::from(body.to_vec()))
                .send()
                .await
                .map_err(|e| ClientErr::HttpClient(format!("{:?}", e)))?
        };

My guess is that the issue is on the chunked file. This leads me to this question. How does Videos Beta API process chunk videos? Is it possible to give feedback on the cause of video process failure if i provide the video_id?

Thanks

welcome[bot] commented 2 years ago

Thank you for creating the issue! One of our team members will get back to you shortly with additional information. If this is a product issue, please close this and contact the particular product's support instead (see https://support.microsoft.com/allproducts for the list of support websites).