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}'"}