Feat: Client admin uploads (#952)
* convert uploads to ts * add custom headers to request * uploads resource * uploads routes updates * index export * add oas * remove delete uploads endpoint * add new package for form-data * remove exports for delete upload endpoint * remove dev package from medusa-js * automatic package upgrade of medusa
This commit is contained in:
@@ -19,6 +19,7 @@ import AdminStoresResource from "./store"
|
||||
import AdminShippingOptionsResource from "./shipping-options"
|
||||
import AdminRegionsResource from "./regions"
|
||||
import AdminNotificationsResource from "./notifications"
|
||||
import AdminUploadsResource from "./uploads"
|
||||
|
||||
class Admin extends BaseResource {
|
||||
public auth = new AdminAuthResource(this.client)
|
||||
@@ -41,6 +42,7 @@ class Admin extends BaseResource {
|
||||
public shippingOptions = new AdminShippingOptionsResource(this.client)
|
||||
public regions = new AdminRegionsResource(this.client)
|
||||
public notifications = new AdminNotificationsResource(this.client)
|
||||
public uploads = new AdminUploadsResource(this.client)
|
||||
}
|
||||
|
||||
export default Admin
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { AdminUploadRes, IAdminPostUploadsFile } from "@medusajs/medusa"
|
||||
import { ResponsePromise } from "../../typings"
|
||||
import BaseResource from "../base"
|
||||
import FormData from "form-data"
|
||||
|
||||
class AdminUploadsResource extends BaseResource {
|
||||
private headers = {
|
||||
"Content-Type": "multipart/form-data",
|
||||
}
|
||||
|
||||
create(file: IAdminPostUploadsFile): ResponsePromise<AdminUploadRes> {
|
||||
const path = `/admin/uploads`
|
||||
|
||||
const payload = new FormData()
|
||||
payload.append("files", file)
|
||||
|
||||
return this.client.request("POST", path, payload, {}, this.headers)
|
||||
}
|
||||
}
|
||||
|
||||
export default AdminUploadsResource
|
||||
Reference in New Issue
Block a user