feedback icon indicating copy to clipboard operation
feedback copied to clipboard

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

Open osain-az opened this issue 3 years ago • 1 comments

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

osain-az avatar May 09 '22 14:05 osain-az

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).

welcome[bot] avatar May 09 '22 14:05 welcome[bot]