通过Javascript API将多个文件上传到Google云端硬盘的最佳策略 [英] Best strategy to upload multiple files to Google Drive via Javascript API

查看:68
本文介绍了通过Javascript API将多个文件上传到Google云端硬盘的最佳策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,该项目需要通过API将多个文件上传到Google云端硬盘.文件数可以是几十个,文件大小可以是数兆字节.

I'm working on a project that requires multiple files to be uploaded to Google Drive via the API. The number of files can be in the dozens and their size can be in multiple Megabytes.

我的问题是:将文件一一发送到Google云端硬盘是一种更好的策略,还是应该并行发送一堆文件? Google云端硬盘会并行处理请求还是只是按一个接一个的顺序执行?是否有描述此行为的文档?

My question is this: Is it a better strategy to send the files one-by-one to Google Drive, or should I send a bunch of files in parallel? Does Google Drive parallelize the requests or just perform them in sequence one-by-one? Is there any documentation that describes this behavior?

提前谢谢!

推荐答案

好,所以在我看来,无论您是一次发送还是批量发送文件,实际上它们都是按一种方式处理的,一个.

OK, so it seems to me that regardless of whether you send the files one-by-one or in bulk, they are in practicality handled one-by-one.

我进行了一项测试,其中我并行上传了1个文件,2个文件,3个文件,4个文件,5个文件和10个文件,并记录了它们所花费的时间.我对每个文件数量执行了9次此操作,并记录了以秒为单位的中值时间.实际上,所有文件都是同一文件(大小约为3 MB):

I've conducted a test in which I uploaded 1 file, 2 files, 3 files, 4 files, 5 files and 10 files in parallel and recorded them time it took. I did this 9 times for each number of files and recorded the median time in seconds. All the files are in fact the same file (approximately 3 MBs in size):

以下是结果:

1个文件:总计9.6秒-每个文件9.6秒

1 file: 9.6 secs total - 9.6 secs per file

2个文件:总计19.7秒-每个文件9.8秒

2 files: 19.7 secs total - 9.8 secs per file

3个文件:总计26​​.5秒-每个文件8.8秒

3 files: 26.5 secs total - 8.8 secs per file

4个文件:总计34.1秒-每个文件8.5秒

4 files: 34.1 secs total - 8.5 secs per file

5个文件:总计44.6秒-每个文件8.9秒

5 files: 44.6 secs total - 8.9 secs per file

10个文件:总计84.1秒-每个文件8.41秒

10 files: 84.1 secs total - 8.41 secs per file

最重要的是,无论您发送Google云端硬盘有多少个上传请求(假设您没有收到403),每个文件所用的时间是相同的.就我而言,每个文件8-9秒.

The bottom line is that regardless of how many upload requests you send Google Drive (assuming you don't get a 403), the amount of time it would take per file is the same. In my case, 8-9 seconds per file.

我想上传请求已排在Google的末端.

I guess the upload requests are queued on Google's end.

这篇关于通过Javascript API将多个文件上传到Google云端硬盘的最佳策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆