Skip to content

Upload File

  • Endpoint Path: /api/v2/common/upload-file
  • Method: POST
  • Request: multipart/form-data

Headers Optional Parameter

Parameter NamePublic Mode (Required)Private Mode (Required)
X-Fresns-Aidrequiredrequired
X-Fresns-Aid-Tokenrequiredrequired
X-Fresns-Uidrequiredrequired
X-Fresns-Uid-Tokenrequiredrequired

Form-data Params

Parameter NameTypeRequiredDescription
usageTypeNumberrequiredFile usage type
tableNameStringrequiredSource table name
users /api/v2/user/edit
posts
comments
conversation_messages /api/v2/conversation/send-message
post_logs /api/v2/editor/{type}/{draftId}
comment_logs /api/v2/editor/{type}/{draftId}
tableColumnStringrequiredSource column name, default is id
tableIdNumberoptionalSource table primary ID
tableKeyStringoptionalSource table key name
typeStringrequiredChoose one from image, video, audio, document
uploadModeStringrequiredChoose one from
file Upload file
fileInfo Upload file information
fileInfoArrayoptionalFor uploadMode=fileInfo only, upload file information array
moreJsonObjectoptionalFor uploadMode=file only, optional
fileFileoptionalFor uploadMode=file only, upload file

Request Description

  • The fileInfo parameter example is shown below. The parameter types can be found in the files table structure.
json
[
    {
        "name": "Store to files->name",
        "mime": "Store to files->mime",
        "extension": "Store to files->extension",
        "size": "Store to files->size", // Unit Byte
        "md5": "Store to files->md5",
        "sha": "Store to files->sha",
        "shaType": "Store to files->sha_type",
        "disk": "Store to files->disk",
        "path": "Store to files->path",
        "imageHandlePosition": "Store to files->image_handle_position",
        "imageWidth": "Image specific, store to files->image_width",
        "imageHeight": "Image specific, store to files->image_height",
        "videoTime": "Video specific, store to files->video_time",
        "videoPosterPath": "Video specific, store to files->video_poster_path",
        "audioTime": "Audio specific, store to files->audio_time",
        "transcodingState": "Audio and video specific, store to files->transcoding_state",
        "moreJson": {
            // Extended information, store to files->more_json
        },
        "originalPath": "Store to files->original_path",
        "rating": "Store to file_usages->rating",
    }
]

Return

uploadMode = file

json
{
    "code": 0,
    "message": "ok",
    "data": {
        // Common Data Structure -> File Info
    }
}

uploadMode = fileInfo

json
{
    "code": 0,
    "message": "ok",
    "data": [
        {
            // Common Data Structure -> File Info
        }
    ]
}

Released under the Apache-2.0 License