Simple Google App Engine application for creating single-use file downloads.
- Deploy the app.yaml at the root of this project to your App Engine project
- Create an App Engine project and enable the default GCS bucket.
- Create a "downloads" directory in the GCS bucket.
- Upload the file you want to deliver into the downloads directory.
- Create a key file named the same as the above file with ".key.txt" added to the end of the file name. (see below for format of this file)
- Upload this key file into the downloads directory.
Key files are plain text files in this form:
key|ttl
- key: Any string without pipe characters.
- ttl: Time in seconds that the download will be valid for after it is first used.
Download links are in this form:
https://APP_ID.appspot.com/downloads/filename?key=key
Replace APP_ID with the application ID of your Google Cloud Platform project.
Once a download link is used for the first time, the key file in GCS will be rewritten with a expiration timestamp in place of the TTL value.
In default GCS bucket:
downloads
├── some_file.jpg
└── some_file.jpg.key.txt
Contents of some_file.jpg.key.txt:
c17a852292ae482eaf2cd4decfbf23d1|900
This link will be active for 15 minutes after it is first used:
https://APP_ID.appspot.com/download/some_file.jpg?key=c17a852292ae482eaf2cd4decfbf23d1