App Engine无法下载超过33MB的内容 [英] App Engine Fails to Download Greater Than 33MB

查看:43
本文介绍了App Engine无法下载超过33MB的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码直接来自

The code below is straight from google apis github for downloading a file from GCS. I changed it to be able to download a file to my local computer.

如果文件大于33MB,则应用将在2分钟或更短的时间内停止尝试.我想我读到了App Engine的限制是32或33.不过,我看不到配额有任何增加的余地.有人可以为我指出正确的管理方法吗?

If the file is larger than 33MB the app will stop attempting after 2 min or less. I think I read that app engine's limit is 32 or 33. I don't see anything in quotas to increase though. Can someone point me in the right direction as to how to manage this?

    if (blob.getSize() < 1_000_000) {
        // Blob is small read all its content in one request
        byte[] content = blob.getContent();
        outStream.write(content);
        outStream.close();
    } else {
        // When Blob size is big or unknown use the blob's channel reader.
        try (ReadChannel reader = blob.reader()) {
            WritableByteChannel channel = Channels.newChannel(outStream);
            ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
            while (reader.read(bytes) > 0) {
                bytes.flip();
                channel.write(bytes);
                bytes.clear();
            }
        }
    }

推荐答案

将客户端发送到直接链接.直接链接没有限制.通过在GCP中设置正确的ACL和/或权限,确保客户端可以访问链接.不要对公众开放,请小心链接的安全性.

Send the client to a direct link. A direct link has no limits. Ensure the link can be accessed by the client by setting the correct ACL's and/or permissions in GCP. Be careful about the link's security by not opening it up to the public.

response.sendRedirect("google.com");

response.sendRedirect("google.com");

这篇关于App Engine无法下载超过33MB的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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