import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.upload.presignedUrl({
name: "test.txt",
size: 1000,
type: "text/plain",
})){
"url": "<string>",
"filename": "<string>",
"originalname": "<string>",
"mime_type": "text/csv",
"extension": "csv",
"size": 123
}Get a presigned URL for uploading a file to the configured File Module Provider. The presigned URL can be used to upload files directly to the third-party provider. This only works if your configured provider supports presigned URLs, such as the S3 provider.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.upload.presignedUrl({
name: "test.txt",
size: 1000,
type: "text/plain",
})){
"url": "<string>",
"filename": "<string>",
"originalname": "<string>",
"mime_type": "text/csv",
"extension": "csv",
"size": 123
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The details of the file to upload.
The file's original name.
The file's size in bytes.
The file's mime type.
"text/csv"
The access level of the file. If private, the file will not be publicly accessible. The default value depends on the configured File Module Provider.
public, private OK
The result of the pre-signed URL upload request.
The file's pre-signed upload URL.
The file's filename.
The file's orignal name.
The file's mime type.
"text/csv"
The file's extension.
"csv"
The file's size in bytes.