本文介绍了ActiveStorage大文件上传触发Google :: Execution :: Expired的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中实施ActiveStorage时,我们发现当上传12GB大文件时,操作挂起大约10分钟,并且出现错误Google::Execution::Expired或有时是HTTPClient::SendTimeoutError: execution expired.

While implementing ActiveStorage at work we found out that when uploading big file, 12GB , the operations hangs for about 10 minutes and the I get the error Google::Execution::Expired or sometimes HTTPClient::SendTimeoutError: execution expired.

我运行的大多数上传都带有这样的一行:

I am running most uploads with a line like this:

backup.file.attach(io: File.open("/my/file/path.ext"), filename: "myfilename")

是否有一种方法可以使请求持续更长的时间,还是可以避免这种超时的方法.

Is there a way to make the request to last longer or a way to circunvent this timeouts.

到目前为止,此策略对于4GB的上传效果很好.只是在我过度考虑文件大小时才会发生这种情况.在我们这边,时间不是问题,因为这是Cron的一项日常工作.

This strategy has worked fine, so far, for uploads of 4GB. It's just when I go overboard with the file size that this occurs. Time is not a problem on our side since this is a nightly task on a Cron job.

推荐答案

Google Cloud Storage客户端的发送超时默认为1分钟左右. (您会看到10分钟的延迟,因为客户端在遇到超时后会尝试几次以恢复上载.)您可以在config/storage.yml:

The Google Cloud Storage client’s send timeout defaults to 1 minute or so. (You see a delay of 10 minutes because the client tries several times to resume the upload after encountering a timeout.) You can specify a different timeout in seconds in config/storage.yml:

production:
  service: GCS
  credentials: { ... }
  project: my-project
  bucket: my-bucket
  timeout: 120  # 2 minutes

使用timeout: 0禁用发送超时.

这篇关于ActiveStorage大文件上传触发Google :: Execution :: Expired的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 23:15