- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在运行一项在 GCP 存储桶中创建或更新对象的服务。即我的代码检查对象是否存在,如果存在我的代码读取它,更新它并写回它。有时我在尝试读取对象时会遇到异常。我的代码:
Storage storage = googleStorage.get();
BlobId blobId = BlobId.of(STORAGE_BUCKET, "path/to.obj"));
Blob blob = storage.get(blobId);
if (blob == null) return null;
byte[] blobContent = blob.getContent();
...
堆栈跟踪:
...
at com.google.cloud.storage.Blob.getContent(Blob.java:455)
at com.google.cloud.storage.StorageImpl.readAllBytes(StorageImpl.java:461)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:51)
at com.google.cloud.RetryHelper.run(RetryHelper.java:74)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:89)
at com.google.cloud.storage.StorageImpl$16.call(StorageImpl.java:461)
at com.google.cloud.storage.StorageImpl$16.call(StorageImpl.java:464)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.load(HttpStorageRpc.java:588)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:220)
No such object: bucket/path/to.obj
com.google.cloud.storage.StorageException: 404 Not Found
如果对象不存在,我希望在 blob
中得到 null,或者如果 blob
不为 null,我希望能够读取。
此行为导致对象被更新多次(不确定这是因为我的代码重试调用还是因为存储库正在做的事情)。
我使用的是 google-cloud-storage 1.27.0,大约每 ~10K 个对象发生一次。
最佳答案
我已经测试了您提供的代码,它似乎以预期的方式工作 - 如果无法找到云存储对象或路径不正确,Blob 对象将被分配为 null。
失败的发生率非常低。也许如果您使用 RetryParams 配置指数退避类,则可以消除或减少这些故障的影响。
关于java - blob.getContent() 中的 com.google.cloud.storage.StorageException 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50042801/
为什么以下程序不打印我的输入?看来putStr没有接受输入。 getContents如何工作? main = do contents <- getContents when (leng
我正在从一个 Laravel 应用程序向另一个应用程序发布 CSV 文件: 发送: $contents = file_get_contents($filePath); Log::debug('cont
我的程序允许用户指定一个作为输入读取的文件,但是这是可选的。如果用户没有指定文件,我想从命令行读取输入。 到目前为止我有这个: main :: IO() main = do (opts, mbAr
我制作了一个插件,将标记添加到所选文本中。 MyText 当我再次选择文本以更改或取消标记时,仅选择文本,而不选择标记标签(当有前导 p 标签时)。 我如何让tinyMCE选择标记?有没有办法获取选择
我想等到用户输入以 EOF 终止,然后将其全部输出。这不是 getContents 应该做的吗?每次用户按回车键时都会输出以下代码,我做错了什么? import System.IO main = do
我正在尝试使用 Spring 集成电子邮件轮询器和 IMAP 读取 Lotus Notes 中的电子邮件。 一切似乎都运作良好。 收到的javamailMessage的getcontect方法是一个i
我正在尝试使用条形码,当结果出现时 我想将网站链接替换为我的链接。我用过这个方法,但不适合我。 通过 Viwa 网络打开网站后的结果示例 https://domainexplem//#/home/11
我使用 javax.mail.internet.MimeBody* 版本 1.4.1 我的程序想要使用 MimeMultiPart 将一些具有多层嵌套的二进制数据从服务器发送到客户端。我观察到,如果我
tinymce.get('content').getContent 不工作。 这是我的代码。你可以看到我尝试过的不同事情的所有不同评论。我有 alert('end'); 最后只是作为测试来查看代码是否
在 android API 7+ 中有什么方法可以报告对 HttpEntity.getContent() 的调用进度? 在我的例子中,我在响应流中获取图像,因此传输可能需要相当长的时间。我想要一个样式
我有一个 URL,正在尝试写入 Linux 机器上的文件。 我可以做一个 wget http://localhost/fileIwant.text 一切都很好。 当我尝试像这样使用 Ja
public InputStream getInputStream() { AndroidHttpClient client = AndroidHttpClient.newInstance(U
在我在 Haskell 中掌握惰性 IO 的过程中,我尝试了以下方法: main = do chars IO () consume [] = return () consume ('x':_)
我正在通过 Guzzle 调用 API。 public function request(string $method, string $uri, array $data = [], array $h
我有一个带有 TinyMCE 文本区域的页面,用于接受一些输入。当用户输入类似的内容时 #WorldCupRio http://www.ball.com/us/experience?story=hel
当我从 POP3 收到电子邮件时,出现以下错误 Fatal exception java.io.IOException: Unknown encoding: 8bitPrecedence at jav
我不知道该怎么做,而我只是想很快地将某些东西弄混。 但是,这就是我所拥有的: public void newScanThing(String scanFormat, String scanConten
我的手有问题。 我有一个 URL,当我启动到该 URL 的连接并执行 url.getContent() 时。响应的类型为 sun.net.www.protocol.http.HttpURLConnec
更新:我自己在下面发布了可能的解决方案 我需要我的程序来读取单元格。如果它包含一个特定的字符串,比如说名字“Jacob”,那么它需要执行稍后在代码中定义的某个静态函数。 我的 IF 语句将嵌套在 wh
我正在使用传单创建一个应用程序,我的 JavaScript 经验几乎为零,所以请耐心等待...... 我已启动并运行传单 map ,并拥有包含 USGS 流数据的 Web 要素服务,但所有信息均以米为
我是一名优秀的程序员,十分优秀!