问题
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