fluentcart-developer 2.0.2 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -59
- package/dist/cards/fluentcart/tools.d.ts.map +1 -1
- package/dist/cards/fluentcart/tools.js +184 -18
- package/dist/cards/fluentcart/tools.js.map +1 -1
- package/dist/skills/fluentcart-developer/.claude-plugin/plugin.json +12 -12
- package/dist/skills/fluentcart-developer/.mcp.json +11 -11
- package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
- package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
- package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
- package/dist/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +1355 -1355
- package/dist/skills/fluentcart-developer/references/action-hooks-customers-users.md +266 -266
- package/dist/skills/fluentcart-developer/references/action-hooks-licenses.md +855 -855
- package/dist/skills/fluentcart-developer/references/action-hooks-orders.md +631 -631
- package/dist/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +963 -963
- package/dist/skills/fluentcart-developer/references/action-hooks-products-coupons.md +585 -585
- package/dist/skills/fluentcart-developer/references/action-hooks-subscriptions.md +661 -661
- package/dist/skills/fluentcart-developer/references/database-models-query-builder.md +194 -194
- package/dist/skills/fluentcart-developer/references/database-models-reference.md +604 -604
- package/dist/skills/fluentcart-developer/references/engineering-notes.md +154 -154
- package/dist/skills/fluentcart-developer/references/fee-system-guide.md +449 -449
- package/dist/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +1202 -1202
- package/dist/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +1598 -1598
- package/dist/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +628 -628
- package/dist/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +1177 -1177
- package/dist/skills/fluentcart-developer/references/fluentcart-developer-guide.md +154 -154
- package/dist/skills/fluentcart-developer/references/ghost-product-selling.md +458 -458
- package/dist/skills/fluentcart-developer/references/modules-and-extensions-reference.md +224 -224
- package/dist/skills/fluentcart-developer/references/payment-gateway-integration.md +761 -761
- package/dist/skills/fluentcart-developer/references/rest-api-customer-profile.md +190 -190
- package/dist/skills/fluentcart-developer/references/rest-api-customers.md +1121 -1121
- package/dist/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +219 -219
- package/dist/skills/fluentcart-developer/references/rest-api-email-notifications.md +619 -619
- package/dist/skills/fluentcart-developer/references/rest-api-files.md +290 -290
- package/dist/skills/fluentcart-developer/references/rest-api-integrations.md +324 -324
- package/dist/skills/fluentcart-developer/references/rest-api-labels-attributes.md +321 -321
- package/dist/skills/fluentcart-developer/references/rest-api-order-bumps.md +200 -200
- package/dist/skills/fluentcart-developer/references/rest-api-overview.md +131 -131
- package/dist/skills/fluentcart-developer/references/rest-api-public-shop.md +172 -172
- package/dist/skills/fluentcart-developer/references/rest-api-reference.md +552 -552
- package/dist/skills/fluentcart-developer/references/rest-api-reports.md +377 -377
- package/dist/skills/fluentcart-developer/references/rest-api-roles-permissions.md +147 -147
- package/dist/skills/fluentcart-developer/references/rest-api-settings.md +528 -528
- package/dist/skills/fluentcart-developer/references/rest-api-shipping.md +799 -799
- package/dist/skills/fluentcart-developer/references/rest-api-tax.md +356 -356
- package/dist/skills/fluentcart-developer/references/subscription-customization.md +197 -197
- package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +65 -65
- package/dist/skills/fluentcart-developer/references/client-integration-contract.md +0 -299
- package/dist/skills/fluentcart-developer/references/device-licensing-and-hardware-tracking.md +0 -241
- package/dist/skills/fluentcart-developer/references/trial-abuse-prevention.md +0 -304
|
@@ -1,290 +1,290 @@
|
|
|
1
|
-
# Files API
|
|
2
|
-
|
|
3
|
-
Upload, manage, list, and delete downloadable product files across local and cloud storage drivers (S3, Bunny, R2), and upload image assets to the WordPress Media Library for the rich text editor in FluentCart.
|
|
4
|
-
|
|
5
|
-
**Base URL:** `https://your-site.com/wp-json/fluent-cart/v2`
|
|
6
|
-
**Policies:** `StoreSensitivePolicy` (File Management) / `AdminPolicy` (Editor Uploads)
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Endpoints Overview
|
|
11
|
-
|
|
12
|
-
| Group | Method | Endpoint | Permission / Policy | Description |
|
|
13
|
-
|-------|--------|----------|--------------------|-------------|
|
|
14
|
-
| **File Management** | GET | `/files` | `store/sensitive` (`StoreSensitivePolicy`) | List files from specified storage driver |
|
|
15
|
-
| | POST | `/files/upload` | `store/sensitive` (`StoreSensitivePolicy`) | Upload downloadable file (`multipart/form-data`) |
|
|
16
|
-
| | GET | `/files/bucket-list` | `store/sensitive` (`StoreSensitivePolicy`) | Retrieve available storage buckets for driver |
|
|
17
|
-
| | DELETE | `/files/delete` | `store/sensitive` (`StoreSensitivePolicy`) | Delete file from storage (`manage_options` for local) |
|
|
18
|
-
| **Editor Uploads** | POST | `/upload-editor-file` | `is_super_admin` (`AdminPolicy`) | Upload image to WP Media Library for description editor |
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## File Management
|
|
23
|
-
|
|
24
|
-
Manage digital downloadable product files across active storage drivers (local filesystem, Amazon S3, DigitalOcean Spaces, Cloudflare R2, etc.).
|
|
25
|
-
|
|
26
|
-
**Base URL:** `https://your-site.com/wp-json/fluent-cart/v2/files`
|
|
27
|
-
**Policy:** `StoreSensitivePolicy` | **Permission:** `store/sensitive`
|
|
28
|
-
|
|
29
|
-
### List Files
|
|
30
|
-
|
|
31
|
-
`GET /fluent-cart/v2/files`
|
|
32
|
-
|
|
33
|
-
Retrieve a paginated list of files stored under the specified driver.
|
|
34
|
-
|
|
35
|
-
#### Parameters
|
|
36
|
-
|
|
37
|
-
| Parameter | Type | Location | Required | Description |
|
|
38
|
-
|-----------|------|----------|----------|-------------|
|
|
39
|
-
| `driver` | string | query | No | Storage driver key (default: `local`). Supported values depend on active drivers |
|
|
40
|
-
| `search` | string | query | No | Case-insensitive substring search filter |
|
|
41
|
-
| `per_page` | integer | query | No | Maximum number of files to return (default: 10) |
|
|
42
|
-
|
|
43
|
-
#### Response
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
{
|
|
47
|
-
"files": [
|
|
48
|
-
{
|
|
49
|
-
"name": "ebook__fluent-cart__.1710345600.pdf",
|
|
50
|
-
"size": 2048576,
|
|
51
|
-
"driver": "local",
|
|
52
|
-
"bucket": ""
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"name": "software-v2__fluent-cart__.1710345700.zip",
|
|
56
|
-
"size": 10485760,
|
|
57
|
-
"driver": "local",
|
|
58
|
-
"bucket": ""
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### Example
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
curl -X GET "https://example.com/wp-json/fluent-cart/v2/files?driver=local&search=ebook&per_page=20" \
|
|
68
|
-
-u "username:app_password"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
### Upload File
|
|
74
|
-
|
|
75
|
-
`POST /fluent-cart/v2/files/upload`
|
|
76
|
-
|
|
77
|
-
Upload a downloadable file. Files are assigned a unique timestamp suffix (`name__fluent-cart__.1710345600.ext`) to prevent name collisions.
|
|
78
|
-
|
|
79
|
-
**Content-Type:** `multipart/form-data`
|
|
80
|
-
|
|
81
|
-
#### Parameters
|
|
82
|
-
|
|
83
|
-
| Parameter | Type | Location | Required | Description |
|
|
84
|
-
|-----------|------|----------|----------|-------------|
|
|
85
|
-
| `file` | file | body | Yes | File binary data to upload |
|
|
86
|
-
| `name` | string | body | Yes | Display name for the file (max 160 chars). File extension is appended automatically |
|
|
87
|
-
| `driver` | string | body | No | Storage driver key (default: `local`) |
|
|
88
|
-
|
|
89
|
-
> **Blocked Extensions (Local Driver):**
|
|
90
|
-
> The local driver blocks executable/script file types by default: `php`, `phtml`, `html`, `htm`, `svg`, `exe`, `sh`, `bat`, `cmd`, `dll`.
|
|
91
|
-
> *Customizable via filter hook:* `fluent_cart/local_file_blocked_extensions`.
|
|
92
|
-
|
|
93
|
-
#### Response
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"message": "File Uploaded Successfully",
|
|
98
|
-
"path": "my-ebook__fluent-cart__.1710345600.pdf",
|
|
99
|
-
"file": {
|
|
100
|
-
"driver": "local",
|
|
101
|
-
"size": 2048576,
|
|
102
|
-
"name": "my-ebook__fluent-cart__.1710345600.pdf",
|
|
103
|
-
"bucket": ""
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
#### Error Response
|
|
109
|
-
|
|
110
|
-
```json
|
|
111
|
-
{
|
|
112
|
-
"message": "Failed To Upload File",
|
|
113
|
-
"additional": "File is empty"
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
#### Example
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
curl -X POST "https://example.com/wp-json/fluent-cart/v2/files/upload" \
|
|
121
|
-
-u "username:app_password" \
|
|
122
|
-
-F "file=@/path/to/ebook.pdf" \
|
|
123
|
-
-F "name=my-ebook" \
|
|
124
|
-
-F "driver=local"
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
### Get Bucket List
|
|
130
|
-
|
|
131
|
-
`GET /fluent-cart/v2/files/bucket-list`
|
|
132
|
-
|
|
133
|
-
Retrieve available storage buckets for cloud storage drivers (e.g. S3, R2).
|
|
134
|
-
|
|
135
|
-
#### Parameters
|
|
136
|
-
|
|
137
|
-
| Parameter | Type | Location | Required | Description |
|
|
138
|
-
|-----------|------|----------|----------|-------------|
|
|
139
|
-
| `driver` | string | query | No | Storage driver key (default: uses the first active driver) |
|
|
140
|
-
|
|
141
|
-
#### Response
|
|
142
|
-
|
|
143
|
-
```json
|
|
144
|
-
{
|
|
145
|
-
"default_bucket": "my-store-files",
|
|
146
|
-
"buckets": [
|
|
147
|
-
{
|
|
148
|
-
"label": "my-store-files",
|
|
149
|
-
"value": "my-store-files"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"label": "my-store-backups",
|
|
153
|
-
"value": "my-store-backups"
|
|
154
|
-
}
|
|
155
|
-
]
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
### Delete File
|
|
162
|
-
|
|
163
|
-
`DELETE /fluent-cart/v2/files/delete`
|
|
164
|
-
|
|
165
|
-
Delete a file from the specified storage driver.
|
|
166
|
-
|
|
167
|
-
> **Permission Note (Local Driver):** Deleting files from the local driver requires the WordPress `manage_options` administrator capability.
|
|
168
|
-
|
|
169
|
-
#### Parameters
|
|
170
|
-
|
|
171
|
-
| Parameter | Type | Location | Required | Description |
|
|
172
|
-
|-----------|------|----------|----------|-------------|
|
|
173
|
-
| `file_path` | string | query | Yes | Relative file path in storage directory |
|
|
174
|
-
| `driver` | string | query | Yes | Storage driver key (e.g., `local`, `s3`) |
|
|
175
|
-
| `bucket` | string | query | No | Bucket name (required for cloud storage drivers) |
|
|
176
|
-
|
|
177
|
-
#### Response
|
|
178
|
-
|
|
179
|
-
```json
|
|
180
|
-
{
|
|
181
|
-
"message": "File Deleted Successfully",
|
|
182
|
-
"driver": "local",
|
|
183
|
-
"path": "my-ebook__fluent-cart__.1710345600.pdf"
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
#### Error Responses
|
|
188
|
-
|
|
189
|
-
```json
|
|
190
|
-
{
|
|
191
|
-
"message": "File not found"
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
```json
|
|
196
|
-
{
|
|
197
|
-
"message": "You are not allowed to delete file"
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
#### Example
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
curl -X DELETE "https://example.com/wp-json/fluent-cart/v2/files/delete?file_path=my-ebook__fluent-cart__.1710345600.pdf&driver=local" \
|
|
205
|
-
-u "username:app_password"
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Editor File Upload
|
|
211
|
-
|
|
212
|
-
Upload images to the WordPress Media Library for product description block editors.
|
|
213
|
-
|
|
214
|
-
**Prefix:** `/fluent-cart/v2/upload-editor-file` | **Policy:** `AdminPolicy` | **Permission:** `is_super_admin`
|
|
215
|
-
**Content-Type:** `multipart/form-data`
|
|
216
|
-
|
|
217
|
-
### Upload Editor File
|
|
218
|
-
|
|
219
|
-
`POST /fluent-cart/v2/upload-editor-file`
|
|
220
|
-
|
|
221
|
-
Uploads an image file to the WordPress Media Library via `media_handle_upload`. Only valid image MIME types are allowed (`image/jpeg`, `image/png`, `image/gif`, `image/webp`).
|
|
222
|
-
|
|
223
|
-
#### Parameters
|
|
224
|
-
|
|
225
|
-
| Parameter | Type | Location | Required | Description |
|
|
226
|
-
|-----------|------|----------|----------|-------------|
|
|
227
|
-
| `file` | file | body | Yes | Image binary file to upload |
|
|
228
|
-
|
|
229
|
-
#### Response
|
|
230
|
-
|
|
231
|
-
Returns standard WordPress attachment payload prepared via `wp_prepare_attachment_for_js`.
|
|
232
|
-
|
|
233
|
-
```json
|
|
234
|
-
{
|
|
235
|
-
"id": 456,
|
|
236
|
-
"title": "product-banner",
|
|
237
|
-
"filename": "product-banner.jpg",
|
|
238
|
-
"url": "https://example.com/wp-content/uploads/2025/01/product-banner.jpg",
|
|
239
|
-
"link": "https://example.com/?attachment_id=456",
|
|
240
|
-
"alt": "",
|
|
241
|
-
"author": "1",
|
|
242
|
-
"description": "",
|
|
243
|
-
"caption": "",
|
|
244
|
-
"name": "product-banner",
|
|
245
|
-
"status": "inherit",
|
|
246
|
-
"uploadedTo": 0,
|
|
247
|
-
"date": "2025-01-15T12:00:00.000Z",
|
|
248
|
-
"modified": "2025-01-15T12:00:00.000Z",
|
|
249
|
-
"menuOrder": 0,
|
|
250
|
-
"mime": "image/jpeg",
|
|
251
|
-
"type": "image",
|
|
252
|
-
"subtype": "jpeg",
|
|
253
|
-
"icon": "https://example.com/wp-includes/images/media/default.png",
|
|
254
|
-
"dateFormatted": "January 15, 2025",
|
|
255
|
-
"nonces": {},
|
|
256
|
-
"editLink": "https://example.com/wp-admin/post.php?post=456&action=edit",
|
|
257
|
-
"meta": false,
|
|
258
|
-
"authorName": "admin",
|
|
259
|
-
"authorLink": "https://example.com/wp-admin/profile.php",
|
|
260
|
-
"filesizeInBytes": 204800,
|
|
261
|
-
"filesizeHumanReadable": "200 KB",
|
|
262
|
-
"sizes": {
|
|
263
|
-
"thumbnail": {
|
|
264
|
-
"url": "https://example.com/wp-content/uploads/2025/01/product-banner-150x150.jpg",
|
|
265
|
-
"height": 150,
|
|
266
|
-
"width": 150
|
|
267
|
-
},
|
|
268
|
-
"medium": {
|
|
269
|
-
"url": "https://example.com/wp-content/uploads/2025/01/product-banner-300x200.jpg",
|
|
270
|
-
"height": 200,
|
|
271
|
-
"width": 300
|
|
272
|
-
},
|
|
273
|
-
"full": {
|
|
274
|
-
"url": "https://example.com/wp-content/uploads/2025/01/product-banner.jpg",
|
|
275
|
-
"height": 800,
|
|
276
|
-
"width": 1200
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
"height": 800,
|
|
280
|
-
"width": 1200
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
#### Example
|
|
285
|
-
|
|
286
|
-
```bash
|
|
287
|
-
curl -X POST "https://example.com/wp-json/fluent-cart/v2/upload-editor-file" \
|
|
288
|
-
-u "username:app_password" \
|
|
289
|
-
-F "file=@/path/to/product-banner.jpg"
|
|
290
|
-
```
|
|
1
|
+
# Files API
|
|
2
|
+
|
|
3
|
+
Upload, manage, list, and delete downloadable product files across local and cloud storage drivers (S3, Bunny, R2), and upload image assets to the WordPress Media Library for the rich text editor in FluentCart.
|
|
4
|
+
|
|
5
|
+
**Base URL:** `https://your-site.com/wp-json/fluent-cart/v2`
|
|
6
|
+
**Policies:** `StoreSensitivePolicy` (File Management) / `AdminPolicy` (Editor Uploads)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Endpoints Overview
|
|
11
|
+
|
|
12
|
+
| Group | Method | Endpoint | Permission / Policy | Description |
|
|
13
|
+
|-------|--------|----------|--------------------|-------------|
|
|
14
|
+
| **File Management** | GET | `/files` | `store/sensitive` (`StoreSensitivePolicy`) | List files from specified storage driver |
|
|
15
|
+
| | POST | `/files/upload` | `store/sensitive` (`StoreSensitivePolicy`) | Upload downloadable file (`multipart/form-data`) |
|
|
16
|
+
| | GET | `/files/bucket-list` | `store/sensitive` (`StoreSensitivePolicy`) | Retrieve available storage buckets for driver |
|
|
17
|
+
| | DELETE | `/files/delete` | `store/sensitive` (`StoreSensitivePolicy`) | Delete file from storage (`manage_options` for local) |
|
|
18
|
+
| **Editor Uploads** | POST | `/upload-editor-file` | `is_super_admin` (`AdminPolicy`) | Upload image to WP Media Library for description editor |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## File Management
|
|
23
|
+
|
|
24
|
+
Manage digital downloadable product files across active storage drivers (local filesystem, Amazon S3, DigitalOcean Spaces, Cloudflare R2, etc.).
|
|
25
|
+
|
|
26
|
+
**Base URL:** `https://your-site.com/wp-json/fluent-cart/v2/files`
|
|
27
|
+
**Policy:** `StoreSensitivePolicy` | **Permission:** `store/sensitive`
|
|
28
|
+
|
|
29
|
+
### List Files
|
|
30
|
+
|
|
31
|
+
`GET /fluent-cart/v2/files`
|
|
32
|
+
|
|
33
|
+
Retrieve a paginated list of files stored under the specified driver.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
| Parameter | Type | Location | Required | Description |
|
|
38
|
+
|-----------|------|----------|----------|-------------|
|
|
39
|
+
| `driver` | string | query | No | Storage driver key (default: `local`). Supported values depend on active drivers |
|
|
40
|
+
| `search` | string | query | No | Case-insensitive substring search filter |
|
|
41
|
+
| `per_page` | integer | query | No | Maximum number of files to return (default: 10) |
|
|
42
|
+
|
|
43
|
+
#### Response
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"files": [
|
|
48
|
+
{
|
|
49
|
+
"name": "ebook__fluent-cart__.1710345600.pdf",
|
|
50
|
+
"size": 2048576,
|
|
51
|
+
"driver": "local",
|
|
52
|
+
"bucket": ""
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "software-v2__fluent-cart__.1710345700.zip",
|
|
56
|
+
"size": 10485760,
|
|
57
|
+
"driver": "local",
|
|
58
|
+
"bucket": ""
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Example
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
curl -X GET "https://example.com/wp-json/fluent-cart/v2/files?driver=local&search=ebook&per_page=20" \
|
|
68
|
+
-u "username:app_password"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### Upload File
|
|
74
|
+
|
|
75
|
+
`POST /fluent-cart/v2/files/upload`
|
|
76
|
+
|
|
77
|
+
Upload a downloadable file. Files are assigned a unique timestamp suffix (`name__fluent-cart__.1710345600.ext`) to prevent name collisions.
|
|
78
|
+
|
|
79
|
+
**Content-Type:** `multipart/form-data`
|
|
80
|
+
|
|
81
|
+
#### Parameters
|
|
82
|
+
|
|
83
|
+
| Parameter | Type | Location | Required | Description |
|
|
84
|
+
|-----------|------|----------|----------|-------------|
|
|
85
|
+
| `file` | file | body | Yes | File binary data to upload |
|
|
86
|
+
| `name` | string | body | Yes | Display name for the file (max 160 chars). File extension is appended automatically |
|
|
87
|
+
| `driver` | string | body | No | Storage driver key (default: `local`) |
|
|
88
|
+
|
|
89
|
+
> **Blocked Extensions (Local Driver):**
|
|
90
|
+
> The local driver blocks executable/script file types by default: `php`, `phtml`, `html`, `htm`, `svg`, `exe`, `sh`, `bat`, `cmd`, `dll`.
|
|
91
|
+
> *Customizable via filter hook:* `fluent_cart/local_file_blocked_extensions`.
|
|
92
|
+
|
|
93
|
+
#### Response
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"message": "File Uploaded Successfully",
|
|
98
|
+
"path": "my-ebook__fluent-cart__.1710345600.pdf",
|
|
99
|
+
"file": {
|
|
100
|
+
"driver": "local",
|
|
101
|
+
"size": 2048576,
|
|
102
|
+
"name": "my-ebook__fluent-cart__.1710345600.pdf",
|
|
103
|
+
"bucket": ""
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Error Response
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"message": "Failed To Upload File",
|
|
113
|
+
"additional": "File is empty"
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Example
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
curl -X POST "https://example.com/wp-json/fluent-cart/v2/files/upload" \
|
|
121
|
+
-u "username:app_password" \
|
|
122
|
+
-F "file=@/path/to/ebook.pdf" \
|
|
123
|
+
-F "name=my-ebook" \
|
|
124
|
+
-F "driver=local"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### Get Bucket List
|
|
130
|
+
|
|
131
|
+
`GET /fluent-cart/v2/files/bucket-list`
|
|
132
|
+
|
|
133
|
+
Retrieve available storage buckets for cloud storage drivers (e.g. S3, R2).
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
| Parameter | Type | Location | Required | Description |
|
|
138
|
+
|-----------|------|----------|----------|-------------|
|
|
139
|
+
| `driver` | string | query | No | Storage driver key (default: uses the first active driver) |
|
|
140
|
+
|
|
141
|
+
#### Response
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"default_bucket": "my-store-files",
|
|
146
|
+
"buckets": [
|
|
147
|
+
{
|
|
148
|
+
"label": "my-store-files",
|
|
149
|
+
"value": "my-store-files"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"label": "my-store-backups",
|
|
153
|
+
"value": "my-store-backups"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### Delete File
|
|
162
|
+
|
|
163
|
+
`DELETE /fluent-cart/v2/files/delete`
|
|
164
|
+
|
|
165
|
+
Delete a file from the specified storage driver.
|
|
166
|
+
|
|
167
|
+
> **Permission Note (Local Driver):** Deleting files from the local driver requires the WordPress `manage_options` administrator capability.
|
|
168
|
+
|
|
169
|
+
#### Parameters
|
|
170
|
+
|
|
171
|
+
| Parameter | Type | Location | Required | Description |
|
|
172
|
+
|-----------|------|----------|----------|-------------|
|
|
173
|
+
| `file_path` | string | query | Yes | Relative file path in storage directory |
|
|
174
|
+
| `driver` | string | query | Yes | Storage driver key (e.g., `local`, `s3`) |
|
|
175
|
+
| `bucket` | string | query | No | Bucket name (required for cloud storage drivers) |
|
|
176
|
+
|
|
177
|
+
#### Response
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"message": "File Deleted Successfully",
|
|
182
|
+
"driver": "local",
|
|
183
|
+
"path": "my-ebook__fluent-cart__.1710345600.pdf"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Error Responses
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"message": "File not found"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"message": "You are not allowed to delete file"
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### Example
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
curl -X DELETE "https://example.com/wp-json/fluent-cart/v2/files/delete?file_path=my-ebook__fluent-cart__.1710345600.pdf&driver=local" \
|
|
205
|
+
-u "username:app_password"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Editor File Upload
|
|
211
|
+
|
|
212
|
+
Upload images to the WordPress Media Library for product description block editors.
|
|
213
|
+
|
|
214
|
+
**Prefix:** `/fluent-cart/v2/upload-editor-file` | **Policy:** `AdminPolicy` | **Permission:** `is_super_admin`
|
|
215
|
+
**Content-Type:** `multipart/form-data`
|
|
216
|
+
|
|
217
|
+
### Upload Editor File
|
|
218
|
+
|
|
219
|
+
`POST /fluent-cart/v2/upload-editor-file`
|
|
220
|
+
|
|
221
|
+
Uploads an image file to the WordPress Media Library via `media_handle_upload`. Only valid image MIME types are allowed (`image/jpeg`, `image/png`, `image/gif`, `image/webp`).
|
|
222
|
+
|
|
223
|
+
#### Parameters
|
|
224
|
+
|
|
225
|
+
| Parameter | Type | Location | Required | Description |
|
|
226
|
+
|-----------|------|----------|----------|-------------|
|
|
227
|
+
| `file` | file | body | Yes | Image binary file to upload |
|
|
228
|
+
|
|
229
|
+
#### Response
|
|
230
|
+
|
|
231
|
+
Returns standard WordPress attachment payload prepared via `wp_prepare_attachment_for_js`.
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"id": 456,
|
|
236
|
+
"title": "product-banner",
|
|
237
|
+
"filename": "product-banner.jpg",
|
|
238
|
+
"url": "https://example.com/wp-content/uploads/2025/01/product-banner.jpg",
|
|
239
|
+
"link": "https://example.com/?attachment_id=456",
|
|
240
|
+
"alt": "",
|
|
241
|
+
"author": "1",
|
|
242
|
+
"description": "",
|
|
243
|
+
"caption": "",
|
|
244
|
+
"name": "product-banner",
|
|
245
|
+
"status": "inherit",
|
|
246
|
+
"uploadedTo": 0,
|
|
247
|
+
"date": "2025-01-15T12:00:00.000Z",
|
|
248
|
+
"modified": "2025-01-15T12:00:00.000Z",
|
|
249
|
+
"menuOrder": 0,
|
|
250
|
+
"mime": "image/jpeg",
|
|
251
|
+
"type": "image",
|
|
252
|
+
"subtype": "jpeg",
|
|
253
|
+
"icon": "https://example.com/wp-includes/images/media/default.png",
|
|
254
|
+
"dateFormatted": "January 15, 2025",
|
|
255
|
+
"nonces": {},
|
|
256
|
+
"editLink": "https://example.com/wp-admin/post.php?post=456&action=edit",
|
|
257
|
+
"meta": false,
|
|
258
|
+
"authorName": "admin",
|
|
259
|
+
"authorLink": "https://example.com/wp-admin/profile.php",
|
|
260
|
+
"filesizeInBytes": 204800,
|
|
261
|
+
"filesizeHumanReadable": "200 KB",
|
|
262
|
+
"sizes": {
|
|
263
|
+
"thumbnail": {
|
|
264
|
+
"url": "https://example.com/wp-content/uploads/2025/01/product-banner-150x150.jpg",
|
|
265
|
+
"height": 150,
|
|
266
|
+
"width": 150
|
|
267
|
+
},
|
|
268
|
+
"medium": {
|
|
269
|
+
"url": "https://example.com/wp-content/uploads/2025/01/product-banner-300x200.jpg",
|
|
270
|
+
"height": 200,
|
|
271
|
+
"width": 300
|
|
272
|
+
},
|
|
273
|
+
"full": {
|
|
274
|
+
"url": "https://example.com/wp-content/uploads/2025/01/product-banner.jpg",
|
|
275
|
+
"height": 800,
|
|
276
|
+
"width": 1200
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
"height": 800,
|
|
280
|
+
"width": 1200
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### Example
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
curl -X POST "https://example.com/wp-json/fluent-cart/v2/upload-editor-file" \
|
|
288
|
+
-u "username:app_password" \
|
|
289
|
+
-F "file=@/path/to/product-banner.jpg"
|
|
290
|
+
```
|