Delete a file

更新时间:
复制 MD 格式

You can delete unwanted files directly from the console.

Console operations

  1. Log on to the EMAS console , select Serverless , and then click Enter .

  2. In the navigation pane on the left, select Cloud Storage .

  3. Find the target file and click Delete .

  4. In the dialog box that appears, click OK .

Client calls

The following code is an example:

const options = {
  filePath: path,
  headers: {
    contentDisposition: 'attachment',
  },
};
mpserverless.file.uploadFile(options).then((image) => {
  mpserverless.file.deleteFile({ fileUrl: image.fileUrl });
});

Cloud Function Invocation

The following code is an example:

module.exports = async (ctx) => {
 ​ // ctx.args are the parameters passed from the client.
  const res = await ctx.mpserverless.file.deleteFile({ fileUrl: ctx.args.fileUrl });
  return res;
};