App Engine Fails to Download Greater Than 33MB

青春壹個敷衍的年華 提交于 2021-02-10 16:50:01

问题


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.

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();
            }
        }
    }

回答1:


The max file size for App Engine is 32 MB (except for the Golang environment which is 64 MB). You cannot download a file larger than this from Google Cloud Storage (or any source). When deploying your app, you also cannot include a file larger than 32 MB in the deployment. This is documented here. Look for the paragraph titled Static data limit




回答2:


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");



来源:https://stackoverflow.com/questions/53105488/app-engine-fails-to-download-greater-than-33mb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!