diff --git a/api-reference/v2/uploads/post-apiapps-uploads.mdx b/api-reference/v2/uploads/post-apiapps-uploads.mdx index 7ead85b..9f39419 100644 --- a/api-reference/v2/uploads/post-apiapps-uploads.mdx +++ b/api-reference/v2/uploads/post-apiapps-uploads.mdx @@ -3,9 +3,16 @@ title: Create Upload openapi: post /apps/{appID}/uploads --- +Upload a file to Glide. There are two ways to upload: + +1. **Direct upload (three-step process)**: Create an upload session, upload file bytes to a pre-signed URL, then complete the upload. +2. **URL upload (single step)**: Provide a source URL and Glide will download and store the file for you. + +## Option 1: Direct Upload + Create an upload session and get a pre-signed upload URL. Upload the file bytes to the `uploadLocation`, then call the complete endpoint to finalize the file and receive a public URL. -## Example +### Example ```bash curl --request POST \ @@ -47,4 +54,50 @@ curl --request POST \ --header "Authorization: Bearer $GLIDE_API_KEY" ``` +## Option 2: URL Upload + +Provide a `sourceURL` and Glide will download the file and upload it directly. This completes in a single API call and returns the final URL immediately. + +### Example + +```bash +curl --request POST \ + --url https://api.glideapps.com/apps/$APP_ID/uploads \ + --header "Authorization: Bearer $GLIDE_API_KEY" \ + --header "Content-Type: application/json" \ + --data '{ + "sourceURL": "https://example.com/images/logo.png" + }' +``` + +Response: + +```json +{ + "data": { + "url": "https://storage.googleapis.com/glide-uploads/uploaded-file.png" + } +} +``` + +### Optional Parameters + +You can optionally override the filename and content type: + +```bash +curl --request POST \ + --url https://api.glideapps.com/apps/$APP_ID/uploads \ + --header "Authorization: Bearer $GLIDE_API_KEY" \ + --header "Content-Type: application/json" \ + --data '{ + "sourceURL": "https://example.com/images/logo.png", + "fileName": "my-custom-name.png", + "contentType": "image/png" + }' +``` + +If not provided, the filename is extracted from the URL path or the `Content-Disposition` header, and the content type is taken from the response headers. + +--- + Note that Glide will delete this file within 30 days if the URL is not stored in a table in Glide. diff --git a/openapi/swagger.json b/openapi/swagger.json index 75ea195..59e537a 100644 --- a/openapi/swagger.json +++ b/openapi/swagger.json @@ -2830,34 +2830,97 @@ "responses": { "200": { "description": "", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "type": "object", + "title": "Direct Upload Response", + "description": "Response when using direct upload (with contentType, contentLength, fileName)", + "properties": { + "data": { + "type": "object", + "properties": { + "uploadID": { + "type": "string", + "description": "ID of the upload, e.g., `upload-123`", + "example": "upload-123" + }, + "uploadLocation": { + "type": "string", + "description": "Pre-signed upload URL for the file bytes", + "example": "https://storage.googleapis.com/glide-uploads/example?X-Goog-Algorithm=GOOG4-RSA-SHA256" + } + }, + "required": [ + "uploadID", + "uploadLocation" + ], + "additionalProperties": false + } + }, + "required": [ + "data" + ], + "additionalProperties": false + }, + { + "type": "object", + "title": "URL Upload Response", + "description": "Response when using URL upload (with sourceURL)", + "properties": { + "data": { + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "Public URL of the uploaded file", + "example": "https://storage.googleapis.com/glide-uploads/uploaded-file.png" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + ] + } + } + } + }, + "400": { + "description": "Invalid source URL or download failed (URL upload only)", "content": { "application/json": { "schema": { "type": "object", "properties": { - "data": { + "error": { "type": "object", "properties": { - "uploadID": { - "type": "string", - "description": "ID of the upload, e.g., `upload-123`", - "example": "upload-123" + "type": { + "type": "string" }, - "uploadLocation": { - "type": "string", - "description": "Pre-signed upload URL for the file bytes", - "example": "https://storage.googleapis.com/glide-uploads/example?X-Goog-Algorithm=GOOG4-RSA-SHA256" + "message": { + "type": "string" } }, "required": [ - "uploadID", - "uploadLocation" + "type", + "message" ], "additionalProperties": false } }, "required": [ - "data" + "error" ], "additionalProperties": false } @@ -2865,7 +2928,7 @@ } }, "402": { - "description": "", + "description": "Upload quota exceeded", "content": { "application/json": { "schema": { @@ -2928,8 +2991,40 @@ } } }, + "408": { + "description": "Download timed out (URL upload only)", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "error": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "message": { + "type": "string" + } + }, + "required": [ + "type", + "message" + ], + "additionalProperties": false + } + }, + "required": [ + "error" + ], + "additionalProperties": false + } + } + } + }, "413": { - "description": "", + "description": "File too large", "content": { "application/json": { "schema": { @@ -2977,30 +3072,63 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "contentType": { - "type": "string", - "description": "MIME type of the file, e.g., `image/png`", - "example": "image/png" - }, - "contentLength": { - "type": "number", - "description": "File size in bytes", - "example": 1024 + "oneOf": [ + { + "type": "object", + "title": "Direct Upload", + "description": "Upload file bytes directly (three-step process)", + "properties": { + "contentType": { + "type": "string", + "description": "MIME type of the file, e.g., `image/png`", + "example": "image/png" + }, + "contentLength": { + "type": "number", + "description": "File size in bytes", + "example": 1024 + }, + "fileName": { + "type": "string", + "description": "Name of the file", + "example": "logo.png" + } + }, + "required": [ + "contentType", + "contentLength", + "fileName" + ], + "additionalProperties": false }, - "fileName": { - "type": "string", - "description": "Name of the file", - "example": "logo.png" + { + "type": "object", + "title": "URL Upload", + "description": "Upload from a URL (single-step process)", + "properties": { + "sourceURL": { + "type": "string", + "format": "uri", + "description": "URL to download the file from", + "example": "https://example.com/images/logo.png" + }, + "fileName": { + "type": "string", + "description": "Optional: Override the filename (extracted from URL if not provided)", + "example": "my-logo.png" + }, + "contentType": { + "type": "string", + "description": "Optional: Override the content type (detected from response headers if not provided)", + "example": "image/png" + } + }, + "required": [ + "sourceURL" + ], + "additionalProperties": false } - }, - "required": [ - "contentType", - "contentLength", - "fileName" - ], - "additionalProperties": false + ] } } }