info

更新时间:
复制 MD 格式

This topic describes how to use the info interface to query files.

Note

The SDK version must be 3.1.3 or later.

Method definition

mpserverless.file.info(fileId: String | String[]): Promise<Result[]>

Request parameters

Interface parameters:

Field name

Type

Required

Description

fileId

String or String[]

Yes

The file ID. You can pass an array to query multiple files.

Note
  • For compatibility with SDK versions earlier than 3.1.3, you can also pass a file URL to query file information.

  • If you pass an array, file IDs that do not exist are automatically ignored.

  • You can query a maximum of 50 files at a time.

Return parameters

The returned parameter is an array:

Field

Type

Description

fileId

String

The file ID.

gmtCreate

Int

The time the file was uploaded, in seconds.

gmtModified

Int

The time the file was last modified, in seconds.

name

String

The original name of the file.

size

Int

The file size, in bytes.

type

String

The file type.

url

String

The CDN-accelerated URL for accessing and downloading the file.

Examples

Sample query file:

const image = await mpserverless.file.info("5d916ee7-869f-4b90-8224-2ad15e25****");
console.log(image);

Sample output:

[
    {
        "fileId": "5d916ee7-869f-4b90-8224-2ad15e25****",
        "gmtCreate": 1665220833,
        "gmtModified": 1665220833,
        "name": "hello.png",
        "size": 29661,
        "type": "png",
        "url": "https://mp-c68e6766-2bda-4263-****-29696919923f.cdn.bspapp.com/cloudstorage/4abe575f-19c8-4b9b-b1cc-4fa385d7****.png"
    }
]