๐ Upload file
| Suitable Enviroment | SaaS |
| Private Deployment |
danger
This capability is deprecated. Please use the Storage capability instead.
Requirementsโ
| ONES | @ones-op/node-ability |
|---|---|
| v3.11.40+ | v0.3.8+ |
Overviewโ
Users can upload files (enable larger than 10m) to the plugin storage space workspace through this ability.
Usageโ
Step 1: Installation dependencyโ
Enter the /backend directory of the plugin project, and execute the following command for dependent installation:
npm i @ones-op/node-ability
Ability to useโ
1. Call SDK to get the link to upload the fileโ
Use the uploadFile method to specify the path under the plugin storage space workspace. The uploadFile method will return a file uploaded link url
import { uploadFile } from '@ones-op/node-ability'
export async function uploadFileToPlugin(request: PluginRequest): Promise<PluginResponse> {
const url = await uploadFile()
return {
body: {
res: url,
},
}
}
2. Upload file through a linkโ
Use this url to select the file you want to upload
caution
The default valid time for file upload links is 60 minutes.
Upload method reference
# Replace {{URL}} with the URL obtained in step 1, and replace your uploaded file path in form
curl --location --request POST {{URL}} \
--header 'Cookie: language=zh' \
--form 'file=@"/Users/hosea/Downloads/plugin(3).sql"'
SDKโ
Parameters reference๏ผ@ones-op/node-ability