1 /**
2 * @oas [post] /admin/uploads
3 * operationId: PostUploads
4 * summary: Upload Files
5 * description: Upload files to the configured File Module Provider.
6 * x-authenticated: true
7 * security:
8 * - api_token: []
9 * - cookie_auth: []
10 * - jwt_token: []
11 * requestBody:
12 * content:
13 * application/json:
14 * schema:
15 * oneOf:
16 * - type: object
17 * description: The files to upload
18 * required:
19 * - files
20 * properties:
21 * files:
22 * type: array
23 * description: The upload's files.
24 * items:
25 * oneOf:
26 * - type: object
27 * description: The file's files.
28 * required:
29 * - name
30 * - content
31 * properties:
32 * name:
33 * type: string
34 * title: name
35 * description: The file's name.
36 * content:
37 * type: string
38 * title: content
39 * description: The file's content.
40 * - type: object
41 * description: A File to upload.
42 * externalDocs:
43 * url: https://developer.mozilla.org/en-US/docs/Web/API/File
44 * description: Learn more about the File API
45 * title: files
46 * - type: array
47 * description: list of files to upload.
48 * items:
49 * type: object
50 * description: A File to upload.
51 * externalDocs:
52 * url: https://developer.mozilla.org/en-US/docs/Web/API/File
53 * description: Learn more about the File API
54 * title: FileList
55 * description: The files to upload.
56 * x-codeSamples:
57 * - lang: JavaScript
58 * label: JS SDK
59 * source: |-
60 * import Medusa from "@medusajs/js-sdk"
61 *
62 * export const sdk = new Medusa({
63 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
64 * debug: import.meta.env.DEV,
65 * auth: {
66 * type: "session",
67 * },
68 * })
69 *
70 * sdk.admin.upload.create(
71 * {
72 * files: [
73 * // file uploaded as a binary string
74 * {
75 * name: "test.txt",
76 * content: "test", // Should be the binary string of the file
77 * },
78 * // file uploaded as a File object
79 * new File(["test"], "test.txt", { type: "text/plain" })
80 * ],
81 * }
82 * )
83 * .then(({ files }) => {
84 * console.log(files)
85 * })
86 * - lang: Shell
87 * label: cURL
88 * source: |-
89 * curl -X POST '{backend_url}/admin/uploads' \
90 * -H 'Authorization: Bearer {jwt_token}'
91 * tags:
92 * - Uploads
93 * responses:
94 * "200":
95 * description: OK
96 * content:
97 * application/json:
98 * schema:
99 * $ref: "#/components/schemas/AdminFileListResponse"
100 * "400":
101 * $ref: "#/components/responses/400_error"
102 * "401":
103 * $ref: "#/components/responses/unauthorized"
104 * "404":
105 * $ref: "#/components/responses/not_found_error"
106 * "409":
107 * $ref: "#/components/responses/invalid_state_error"
108 * "422":
109 * $ref: "#/components/responses/invalid_request_error"
110 * "500":
111 * $ref: "#/components/responses/500_error"
112 * x-workflow: uploadFilesWorkflow
113 * x-events: []
114 *
115 */
116