Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

How do I add the original file name to a YouTube API video upload?

$
0
0

How do I set the file name for my YouTube video uploads?

I am uploading via the videos.insert endpoint in the YouTube v3 API.

If I omit the fileDetails part, everything else works as expected.

I tried to add the fileDetails part, like so:

        List<String> parts = []        def videoData = new Video()        // ...omitted code to set up snippet, etc...        // set file details:        def fileDetails = new VideoFileDetails()        fileDetails.setFileName("filename.mp4")        fileDetails.setCreationTime(fileAttributes.creationTime().toInstant().toString())        fileDetails.setFileSize(BigInteger.valueOf(Files.size(videoFileInfo.filePath)))        videoData.setFileDetails(fileDetails)        parts.add('fileDetails')        // upload the video        def mediaContent = new InputStreamContent(VIDEO_FILE_FORMAT, Files.newInputStream(videoFileInfo.filePath))        mediaContent.setLength(Files.size(videoFileInfo.filePath))        def insertCommand = youTube.videos().insert(parts.join(','), videoData, mediaContent)        // ...omitted code to set up progress listener...        def returnedVideo = insertCommand.execute()

I get a 400 response:

POST https://www.googleapis.com/upload/youtube/v3/videos?part=status,snippet,fileDetails&uploadType=resumable{"code" : 400,"errors" : [ {"domain" : "youtube.part","location" : "part","locationType" : "parameter","message" : "'{0}'","reason" : "unexpectedPart"  } ],"message" : "'{0}'"}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>