简体   繁体   中英

Download large file from external server using Google AppEngine with php

I am experimenting with Google AppEngine and trying to download file from external server to my local machine using simple download script in php hosted at AppEngine.

Sample code snippet is as follows:

header('Content-Type: "' . $mime . '"');
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header("Content-Transfer-Encoding: binary");
    header('Expires: 0');
    header('Content-Length: '.$size);
    header('Pragma: no-cache');
}

readfile($url);

This is working fine for small size of the file. But it is failing for larger files due to 60 second execution time limitation of GAE. Is there any workaround to accomplish this type of task?

i can't add comment

from where you are reading file if its from Google Cloud Storage then you can configure your bucket as a static website. read more : https://cloud.google.com/storage/docs/website-configuration

and use Manual Scaling

Requests can run indefinitely. A manually-scaled instance can choose to handle /_ah/start and execute a program or script for many hours without returning an HTTP response code.

read more :: about scaling_types on google

you can save file Google Cloud Storage then access.

if i misunderstand sorry i am also trying to learn Google AppEngine(php) from last month :p another noob

If the file is stored in GCS, you could serve the file directly without the 60s limit. See https://cloud.google.com/appengine/docs/php/googlestorage/public_access#serving_files_directly_from_google_cloud_storage for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM