Welcome to Moves-GAE’s documentation!¶
Images¶
List of Endpoints¶
/upload/image
: Handled byimage_upload()
./upload/image/overlay
: Handled byimage_upload_with_overlay()
.
API Reference¶
-
images.
delete_image
()[source]¶ Deletes an image from Cloud Storage. Requires “post_id” url parameter.
Returns: - 204 - Image successfully deleted.
- 400 - Missing post_id url parameter or no such image found.
-
images.
image_upload
()[source]¶ Endpoint for just image upload.
Expects form data fields “post_id”, “ext” and “content-type” which are used to save the output name. Expects image to be uploaded as multipart/file-upload and accessible under the name “image”.
Returns: - 204 - No content.
- 400 - Missing data field.
- 5XX - Request too large.
Videos¶
List of Endpoints¶
/upload/video
: Handled byvideo_upload()
./upload/video/overlay
: Handled byvideo_upload_with_overlay()
.
API Reference¶
-
videos.
delete_video
()[source]¶ Deletes a video from Cloud Storage. Requires “post_id” url parameter.
Returns: - 204 - Video successfully deleted.
- 400 - Missing post_id url parameter or no such image found.
-
videos.
setup_routing
(app: flask.app.Flask)[source]¶ Basic routing function for flask.
Parameters: app (flask.Flask) – Your flask application object.
-
videos.
video_upload
()[source]¶ This requires “post_id”, “ext” and “content-type” as form data keys along with “video” file key (also form data technically).
Returns: - 204 - No content.
- 400 - Missing data field.
- 5XX - Request too large.
-
videos.
video_upload_with_overlay
()[source]¶ Video upload with an overlay image. This endpoint will schedule transcoding of the video (e.g. it won’t happen in this request call).
Requires an extra “overlay” form data field that must be a PNG.
Returns: - 204 - No content.
- 400 - Missing data field.
- 5XX - Request too large.
Storage¶
Utilities for interacting with Google Cloud Storage.
API Reference¶
-
storage.
delete_image
(filename: str) → bool[source]¶ Deletes an image with the given filename (without extension).
Parameters: filename – Returns: True
if deleted,False
if not found.
-
storage.
delete_video
(filename: str) → bool[source]¶ Deletes a video with the given filename (without extension).
Parameters: filename – Returns: True
if deleted,False
if not found.
-
storage.
generate_image_path
(post_id: str, ext: str) → pathlib.Path[source]¶ Generates the full path to be passed to
upload_data()
.Parameters: - post_id – Output filename, usually gathered from an upload request.
- ext – Output extension, usually gathered from an upload request.
Returns: Full path to be passed to
upload_data()
.
-
storage.
generate_transcoding_path
() → pathlib.Path[source]¶ Generates a directory path that can be used for publishing transcode events.
Returns:
-
storage.
generate_video_path
(output_name: str, ext: str) → pathlib.Path[source]¶ Generates the full path to be passed to
upload_data()
.Parameters: - output_name – Output filename, usually gathered from an upload request.
- ext – Output extension, usually gathered from an upload request.
Returns: Full path to be passed to
upload_data()
.
-
storage.
get_image_url
(filename: str) → typing.Union[str, NoneType][source]¶ Gets an image’s public url based on the filename without extension.
Parameters: filename – Returns: Image’s public URL.
-
storage.
get_public_url
(filename: str) → typing.Union[str, NoneType][source]¶ Get’s a files public url based on the filename. Could be a video or image.
Parameters: filename – Returns: Public URL
-
storage.
get_video_url
(filename: str) → typing.Union[str, NoneType][source]¶ Gets a video’s public url based on the filename without extension.
Parameters: filename – Returns: Video’s public URL
-
storage.
upload_data
(data: _io.BytesIO, content_type: str, full_path: pathlib.Path) → str[source]¶ Uploads binary data to the given path on Google Cloud Storage.
Parameters: - data – Binary data (for now just photos/videos).
- content_type – Correct content type for the data we’re uploading.
- full_path – Full path including bucket.
Raises: ValueError – If
full_path
begins with a leading slash.Returns: Public URL to access file.
Download¶
List of Endpoints¶
/download/image
: Handled bydownload_image()
./download/video
: Handled bydownload_video()
.
API Reference¶
-
download.
download_image
()[source]¶ This function expects a
post_id
URL parameter. Post ID corresponds to the filename w/o extension in Storage. This endpoint should redirect to the file’s location in Storage.Returns: Redirects to the file’s location in Storage.