Cannot upload from Drive via YouTube Data API in Google Apps Script: empty response

后端 未结 1 580
情书的邮戳
情书的邮戳 2021-01-14 04:14

I am trying to import a list of files from Google Drive to YouTube. The meta-data and the URL to the file are in a Google spreadsheet, so I wrote some code using Google Apps

相关标签:
1条回答
  • 2021-01-14 04:30

    I had same problem in my project and here's what I have figured out: if your video file size is more than 10 Mb, you will get Empty response error.

    Probably (can't say officialy because no documentation mentions it) this is happening because Google Apps Script's YouTube.Videos.insert (and all other available built-in services) uses UrlFetchApp under the hood, which have restriction of 10 Mb per call: https://developers.google.com/apps-script/guides/services/quotas#current_limitations. You can check it yourself using your sample code: if file is under 10 Mb, it will be uploaded successfully.

    As possible workaround, you can use idea from this answer: https://stackoverflow.com/a/44853845/555121

    Basically, you will need to open modal window using SpreadsheetApp.getUi().showModalDialog and then perform upload to YouTube via plain JavaScript inside modal dialog, which have no restrictions on transferred data size. Here's good example of YouTube resumable upload implementation: https://github.com/sangnvus/2015SUMJS01/blob/master/WIP/Sources/FlyAwayPlus/FlyAwayPlus/Scripts/youtube-upload.js

    0 讨论(0)
提交回复
热议问题