Reputation: 3285
Running a dart server in App Engine Flexible Environment, there seems to be a limitation of serving files larger than 32MB.
There are a few requirements to files I want to serve:
At the moment I try to read the file from the bucket using the gcloud library and then pipe into the request.response
. This fails because of the limitation e.g.: HTTP response was too large: 33554744. The limit is: 33554432.
Is there a way to serve larger files from storage? The documentation on this topic is quite confusing (I don't think there is dart specific documentation at all). I keep reading something about the Blobstore but I am not sure if this solution is applicable for dart.
Upvotes: 1
Views: 1037
Reputation: 1379
As @filiph suggest you can use signed urls from Google Cloud Storage.
Server side I have this code in python:
import time
import base64
from oauth2client.service_account import ServiceAccountCredentials
def create_signed_url(file_location):
# Get credentials
creds = ServiceAccountCredentials.from_json_keyfile_name('filename_of_private_key.json')
client_id = creds.service_account_email
# Set time limit to two hours from now
timestamp = time.time() + 2 * 3600
# Generate signature string
signature_string = "GET\n\n\n%d\n%s" % (timestamp, file_location)
signature = creds.sign_blob(signature_string)[1]
encoded_signature = base64.b64encode(signature)
encoded_signature = encoded_signature.replace("+", "%2B").replace("/", "%2F")
# Generate url
return "https://storage.googleapis.com%s?GoogleAccessId=%s&Expires=%d&&Signature=%s" % (
file_location, client_id, timestamp, encoded_signature)
Upvotes: 2