Update documentation content
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: API Media DELETE | Datasquirel docs
|
||||
description: Delete a media file via the Datasquirel API
|
||||
page_title: Media DELETE
|
||||
page_description: Delete a media file from your Datasquirel media storage using the API.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Use the Media DELETE endpoint to permanently remove a file from your media storage. Provide the file's database ID to identify which file to delete.
|
||||
|
||||
## npm Package
|
||||
|
||||
```javascript
|
||||
import datasquirel from "@moduletrace/datasquirel";
|
||||
|
||||
const result = await datasquirel.media.delete({
|
||||
mediaID: 23,
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
|
||||
console.log(result.success); // true
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `mediaID` | `string \| number` | Yes | The database ID of the file to delete |
|
||||
| `apiKey` | `string` | No | API key. Falls back to `DATASQUIREL_API_KEY` |
|
||||
|
||||
## REST API
|
||||
|
||||
```
|
||||
DELETE /api/v1/media/{id}
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Authorization: Bearer YOUR_API_KEY
|
||||
```
|
||||
|
||||
## Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"payload": { "id": 23 }
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- A **Full Access** API key is required. Read-only keys cannot delete files.
|
||||
- Deletion is permanent. The file and its thumbnail are both removed from storage.
|
||||
- Use the [Media GET](/docs/api-reference/media/get) endpoint to look up a file's ID before deleting.
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: API Media GET | Datasquirel docs
|
||||
description: Retrieve media file metadata via the Datasquirel API
|
||||
page_title: Media GET
|
||||
page_description: Retrieve a media file or a list of media files using the Datasquirel API.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Use the Media GET endpoint to retrieve metadata for one or more media files. You can look up a file by its database ID, by name, or list all files in a folder.
|
||||
|
||||
## npm Package
|
||||
|
||||
### Get All Media Files
|
||||
|
||||
```javascript
|
||||
import datasquirel from "@moduletrace/datasquirel";
|
||||
|
||||
const result = await datasquirel.media.get({
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
|
||||
console.log(result.payload); // Array of media objects
|
||||
```
|
||||
|
||||
### Get a Single File by ID
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
mediaID: 15,
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
### Get Files in a Specific Folder
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
folder: "profile-images",
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
### Get a File by Name
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
mediaName: "avatar.jpg",
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `mediaID` | `string \| number` | No | The database ID of the media file |
|
||||
| `mediaName` | `string` | No | The file name to look up |
|
||||
| `folder` | `string` | No | Folder name to filter results |
|
||||
| `thumbnail` | `"true" \| "false"` | No | Return thumbnail URL instead of original |
|
||||
| `skipBase64` | `"true" \| "false"` | No | Skip base64 encoding in the response |
|
||||
| `apiKey` | `string` | No | API key. Falls back to `DATASQUIREL_API_KEY` |
|
||||
|
||||
## REST API
|
||||
|
||||
```
|
||||
GET /api/v1/media
|
||||
GET /api/v1/media/{id}
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Authorization: Bearer YOUR_API_KEY
|
||||
```
|
||||
|
||||
## Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"payload": {
|
||||
"id": 15,
|
||||
"name": "avatar.jpg",
|
||||
"folder": "profile-images",
|
||||
"url": "https://your-instance.com/media/profile-images/avatar.jpg",
|
||||
"thumbnail_url": "https://your-instance.com/media/profile-images/thumbs/avatar.jpg",
|
||||
"size": 24576,
|
||||
"mime_type": "image/jpeg"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: API Media Reference | Datasquirel docs
|
||||
description: Manage media files via the Datasquirel API
|
||||
page_title: Media API
|
||||
page_description: Upload, retrieve, and delete media files programmatically using the Datasquirel API.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
The Media API lets you manage files stored in your Datasquirel media storage. Use it to upload files from your application, retrieve file metadata, and delete files that are no longer needed.
|
||||
|
||||
```bash
|
||||
npm install @moduletrace/datasquirel
|
||||
```
|
||||
|
||||
<div className="w-full grid grid-cols-1 gap-4 items-stretch">
|
||||
<DocsCard
|
||||
title="GET"
|
||||
description="Retrieve media file metadata or a list of files."
|
||||
href="/docs/api-reference/media/get"
|
||||
/>
|
||||
<DocsCard
|
||||
title="POST"
|
||||
description="Upload a new media file."
|
||||
href="/docs/api-reference/media/post"
|
||||
/>
|
||||
<DocsCard
|
||||
title="DELETE"
|
||||
description="Delete a media file."
|
||||
href="/docs/api-reference/media/delete"
|
||||
/>
|
||||
</div>
|
||||
|
||||
## Authentication
|
||||
|
||||
All media API requests require a **Full Access** API key. Read-only keys cannot upload or delete media.
|
||||
|
||||
Include your key in the `Authorization` header:
|
||||
|
||||
```
|
||||
Authorization: Bearer YOUR_API_KEY
|
||||
```
|
||||
|
||||
Or pass it as `apiKey` in the npm package function call.
|
||||
@@ -0,0 +1,99 @@
|
||||
---
|
||||
title: API Media POST | Datasquirel docs
|
||||
description: Upload a media file via the Datasquirel API
|
||||
page_title: Media POST
|
||||
page_description: Upload images and files to your Datasquirel media storage programmatically.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Use the Media POST endpoint to upload one or more files to your media storage. Files are stored in the folder you specify, and image thumbnails are generated automatically.
|
||||
|
||||
## npm Package
|
||||
|
||||
```javascript
|
||||
import datasquirel from "@moduletrace/datasquirel";
|
||||
import fs from "fs";
|
||||
|
||||
// Read the file and convert to base64
|
||||
const fileBuffer = fs.readFileSync("./photo.jpg");
|
||||
const base64 = fileBuffer.toString("base64");
|
||||
|
||||
const result = await datasquirel.media.add({
|
||||
media: [
|
||||
{
|
||||
name: "photo.jpg",
|
||||
base64: `data:image/jpeg;base64,${base64}`,
|
||||
},
|
||||
],
|
||||
folder: "profile-images",
|
||||
type: "image",
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
|
||||
console.log(result.payload); // Uploaded media object(s)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `media` | `array` | Yes | Array of files to upload. Each item has a `name` and `base64` string |
|
||||
| `folder` | `string` | No | Destination folder name. Created automatically if it does not exist |
|
||||
| `type` | `string` | Yes | File type — `"image"`, `"video"`, `"audio"`, or `"file"` |
|
||||
| `apiKey` | `string` | No | API key. Falls back to `DATASQUIREL_API_KEY` |
|
||||
|
||||
### media Array Items
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `name` | `string` | The file name including extension (e.g. `"photo.jpg"`) |
|
||||
| `base64` | `string` | Base64-encoded file data. Must include the data URL prefix (e.g. `data:image/jpeg;base64,...`) |
|
||||
|
||||
## REST API
|
||||
|
||||
```
|
||||
POST /api/v1/media
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Authorization: Bearer YOUR_API_KEY
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
**Body:**
|
||||
```json
|
||||
{
|
||||
"media": [
|
||||
{
|
||||
"name": "photo.jpg",
|
||||
"base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."
|
||||
}
|
||||
],
|
||||
"folder": "profile-images",
|
||||
"type": "image"
|
||||
}
|
||||
```
|
||||
|
||||
## Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"payload": [
|
||||
{
|
||||
"id": 23,
|
||||
"name": "photo.jpg",
|
||||
"folder": "profile-images",
|
||||
"url": "https://your-instance.com/media/profile-images/photo.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- A **Full Access** API key is required. Read-only keys cannot upload files.
|
||||
- Image thumbnails are generated automatically and stored alongside the original.
|
||||
- Uploading a file with the same name as an existing file in the same folder will overwrite it if `update: true` is passed.
|
||||
Reference in New Issue
Block a user