@@ -28,18 +28,41 @@ export class UploadController extends Controller {
2828 *
2929 * @summary Upload files to IPFS
3030 * @param files - Array of files to upload (max 5 files, 10MB each)
31+ * @param jsonData - Optional JSON string with additional metadata
3132 * @returns Promise containing upload results with CIDs and any failed uploads
3233 *
3334 * @example
34- * Request:
35+ * Using curl:
36+ * ```bash
37+ * curl -X POST http://api.example.com/v1/upload \
38+ * -F "files=@/path/to/file1.txt" \
39+ * -F "files=@/path/to/file2.txt" \
40+ * -F "jsonData={\"key\":\"value\"}"
3541 * ```
36- * POST /v1/upload
37- * Content-Type: multipart/form-data
3842 *
39- * files: [File, File, ...]
43+ * Using HTML Form:
44+ * ```html
45+ * <form action="/v1/upload" method="post" enctype="multipart/form-data">
46+ * <input type="file" name="files" multiple>
47+ * <input type="hidden" name="jsonData" value='{"key":"value"}'>
48+ * <button type="submit">Upload</button>
49+ * </form>
4050 * ```
4151 *
42- * Success Response:
52+ * Using Fetch API:
53+ * ```javascript
54+ * const formData = new FormData();
55+ * formData.append('files', fileInput.files[0]);
56+ * formData.append('files', fileInput.files[1]);
57+ * formData.append('jsonData', JSON.stringify({key: 'value'}));
58+ *
59+ * fetch('/v1/upload', {
60+ * method: 'POST',
61+ * body: formData
62+ * });
63+ * ```
64+ *
65+ * Success Response (201):
4366 * ```json
4467 * {
4568 * "success": true,
@@ -53,7 +76,7 @@ export class UploadController extends Controller {
5376 * }
5477 * ```
5578 *
56- * Partial Success Response:
79+ * Partial Success Response (207) :
5780 * ```json
5881 * {
5982 * "success": false,
@@ -67,6 +90,29 @@ export class UploadController extends Controller {
6790 * ]
6891 * }
6992 * }
93+ * ```
94+ *
95+ * No Files Error Response (400):
96+ * ```json
97+ * {
98+ * "success": false,
99+ * "message": "No files uploaded",
100+ * "errors": {
101+ * "upload": "No files uploaded"
102+ * }
103+ * }
104+ * ```
105+ *
106+ * Upload Failed Error Response (500):
107+ * ```json
108+ * {
109+ * "success": false,
110+ * "message": "Upload failed",
111+ * "errors": {
112+ * "upload": "Failed to upload file"
113+ * }
114+ * }
115+ * ```
70116 */
71117 @Post ( )
72118 @SuccessResponse ( 201 , "Upload successful" )
0 commit comments