我刚刚开始使用YouTube数据API,并且在块大小方面苦苦挣扎 .
以下是从文档中的PHP代码示例中设置块大小的方法:
// Specify the size of each chunk of data, in bytes. Set a higher value for
// reliable connection as fewer chunks lead to faster uploads. Set a lower
// value for better recovery on less reliable connections.
$chunkSizeBytes = 1 * 1024 * 1024;
经过一些测试我发现 YouTube only accepted the first 5-10 chunks ,然后上传停止(有时它会在2分钟后继续,但只是为了几个块,然后永远停止) .
然后我将块大小增加到10MB(10 * 1024 * 1024),但仍然有同样的问题 . 大量超过50-100MB的文件在几个块之后才会中止 .
现在我已经将块大小设置为100MB(100 * 1024 * 1024),到目前为止工作正常,但我没有测试过1GB文件 .
Why is this happening and how can I fix this?
如果我想上传20GB的视频,我无法想象最好发送5GB的块,是吗?
1 回答
尝试使用Resumable Uploads . 与简单上传相比,可恢复上传是为较大的文件设计的 .