diff --git a/api-reference/v2/uploads/post-apiapps-uploads-uploadid-complete.mdx b/api-reference/v2/uploads/post-apiapps-uploads-uploadid-complete.mdx new file mode 100644 index 0000000..c60eaa7 --- /dev/null +++ b/api-reference/v2/uploads/post-apiapps-uploads-uploadid-complete.mdx @@ -0,0 +1,10 @@ +--- +title: Complete Upload +openapi: post /apps/{appID}/uploads/{uploadID}/complete +--- + +Finalize an upload and receive the public URL for the file. Use the `uploadID` from the create upload response. + +If the uploaded object is missing or incomplete, this endpoint returns a 409. + +Note that Glide will delete this file within 30 days if the URL is not stored in a table in Glide. diff --git a/api-reference/v2/uploads/post-apiapps-uploads.mdx b/api-reference/v2/uploads/post-apiapps-uploads.mdx new file mode 100644 index 0000000..7ead85b --- /dev/null +++ b/api-reference/v2/uploads/post-apiapps-uploads.mdx @@ -0,0 +1,50 @@ +--- +title: Create Upload +openapi: post /apps/{appID}/uploads +--- + +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 + +```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 '{ + "contentType": "image/png", + "contentLength": 1024, + "fileName": "logo.png" + }' +``` + +Response: + +```json +{ + "data": { + "uploadID": "upload-123", + "uploadLocation": "https://storage.googleapis.com/glide-uploads/example?X-Goog-Algorithm=GOOG4-RSA-SHA256" + } +} +``` + +Then upload the file bytes to `uploadLocation`: + +```bash +curl --request PUT \ + --url "$UPLOAD_LOCATION" \ + --header "Content-Type: image/png" \ + --upload-file ./logo.png +``` + +Finally, complete the upload: + +```bash +curl --request POST \ + --url https://api.glideapps.com/apps/$APP_ID/uploads/$UPLOAD_ID/complete \ + --header "Authorization: Bearer $GLIDE_API_KEY" +``` + +Note that Glide will delete this file within 30 days if the URL is not stored in a table in Glide. diff --git a/docs.json b/docs.json index 9856f20..3c7b2a0 100644 --- a/docs.json +++ b/docs.json @@ -48,6 +48,13 @@ "api-reference/v2/jobs/get-job" ] }, + { + "group": "Uploads", + "pages": [ + "api-reference/v2/uploads/post-apiapps-uploads", + "api-reference/v2/uploads/post-apiapps-uploads-uploadid-complete" + ] + }, { "group": "Tutorials", "pages": [ @@ -87,4 +94,4 @@ "linkedin": "https://www.linkedin.com/company/glideapps/" } } -} \ No newline at end of file +} diff --git a/openapi/swagger.json b/openapi/swagger.json index 63721b6..75ea195 100644 --- a/openapi/swagger.json +++ b/openapi/swagger.json @@ -2824,6 +2824,342 @@ ], "description": "Deletes a stash and all its data" } + }, + "/apps/{appID}/uploads": { + "post": { + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "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 + } + } + } + }, + "402": { + "description": "", + "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 + } + } + } + }, + "403": { + "description": "", + "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": "", + "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 + } + } + } + } + }, + "parameters": [ + { + "name": "appID", + "in": "path", + "schema": { + "type": "string", + "description": "ID of the app, e.g., `mT91fPcZCWigkZXgSZGJ`", + "example": "mT91fPcZCWigkZXgSZGJ" + }, + "required": true + } + ], + "requestBody": { + "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 + }, + "fileName": { + "type": "string", + "description": "Name of the file", + "example": "logo.png" + } + }, + "required": [ + "contentType", + "contentLength", + "fileName" + ], + "additionalProperties": false + } + } + } + } + } + }, + "/apps/{appID}/uploads/{uploadID}/complete": { + "post": { + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "Public URL for the uploaded file", + "example": "https://storage.googleapis.com/glide-uploads/example.png" + } + }, + "required": [ + "url" + ], + "additionalProperties": false + } + }, + "required": [ + "data" + ], + "additionalProperties": false + } + } + } + }, + "403": { + "description": "", + "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 + } + } + } + }, + "404": { + "description": "", + "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 + } + } + } + }, + "409": { + "description": "", + "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 + } + } + } + } + }, + "parameters": [ + { + "name": "appID", + "in": "path", + "schema": { + "type": "string", + "description": "ID of the app, e.g., `mT91fPcZCWigkZXgSZGJ`", + "example": "mT91fPcZCWigkZXgSZGJ" + }, + "required": true + }, + { + "name": "uploadID", + "in": "path", + "schema": { + "type": "string", + "description": "ID of the upload, e.g., `upload-123`", + "example": "upload-123" + }, + "required": true + } + ] + } } }, "security": [ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8eb2632 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "api-docs", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}