文件操作

获取文件详情

info v2.1 接口规范了返回参数的输出,使用更方便。原获取文件详情 v1.3 接口已被废弃。

接口

GET /hserve/v2.2/uploaded-file/:file_id/

其中 :file_id 需替换为你的文件 ID

请求示例

  1. curl -X GET \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/uploaded-file/5cac3d2299ecae0c9e8aa3e6/

返回示例

  1. {
  2. "category": [
  3. {
  4. "id": "5cac3d2299ecae0c9e8aa3e6",
  5. "name": "Category",
  6. }
  7. ],
  8. "cdn_path": "1eJCS1MFGdvaaBoV.png",
  9. "created_at": 1511762369,
  10. "id": "5cac3d2299ecae0c9e8aa3e6",
  11. "mime_type": "image/png",
  12. "name": "box_close.png",
  13. "path": "https://cloud-minapp-287.cloud.ifanrusercontent.com/1eJCS1MFGdvaaBoV.png",
  14. "size": 3652,
  15. }

获取文件列表

info v2.2 接口规范了返回参数的输出,使用更方便。原获取文件列表 v1.3 接口已被废弃。

接口

GET /hserve/v2.2/uploaded-file/

info 该接口支持通过参数 return_total_count 指定是否返回查询对象总数,以协助不关心对象总数只关心查询结果列表的开发者提升接口响应速度。 同时,从 v2.2 版本开始该接口默认不返回查询对象总数,欲获取总数的开发者需要显式指定 return_total_count 参数。

参数说明

参数 类型 必填 说明
order_by string Y 排序(支持 created_at 进行排序)
limit integer N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
offset integer N 设置返回资源的起始偏移值,默认为 0
return_total_count integer N 返回结果 meta 中是否返回 total_count,1 为返回,0 为不返回,默认不返回

若开发者只需要获取对象总数,则可以通过设置 limit=1 以及 return_total_count=1 来达到该效果,total_count 可从返回的 meta 中获取

请求示例:

  1. https://{{服务器域名}}/hserve/v2.2/uploaded-file/?limit=1&return_total_count=1

请求示例

  1. curl -X GET \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -G \
  6. --data-urlencode "order_by=-created_at" \
  7. https://{{服务器域名}}/hserve/v2.2/uploaded-file/

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 5
  8. },
  9. "objects": [
  10. {
  11. "category": null,
  12. "created_at": 1546008508,
  13. "id": "5cac3d2299ecae0c9e8aa3e6",
  14. "mime_type": "image/jpeg",
  15. "name": "test.jpeg",
  16. "path": "https://cloud-minapp-18630.cloud.ifanrusercontent.com/1gctR6qybW3irhEo.jpeg",
  17. "size": 27273,
  18. "cdn_path": "1gctR6qybW3irhEo.jpeg"
  19. },
  20. ......
  21. ]
  22. }

删除文件

info v2.1 接口规范了返回参数的输出,使用更方便。原删除文件 v1.3 接口已被废弃。

接口

DELETE https://{{服务器域名}}/hserve/v2.2/uploaded-file/:file_id/

其中 :file_id 需替换为你的文件 ID

请求示例

  1. curl -X DELETE \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/uploaded-file/5a1ba9c1fff1d651135e5ff1/

状态码说明

204 删除成功

批量删除文件

info v2.1 接口规范了返回参数的输出,使用更方便。原批量删除文件 v1.3 接口已被废弃。

接口

DELETE /hserve/v2.2/uploaded-file/

提交参数

id__in 包含多个文件 ID, ID 之间通过 , 分隔

请求示例

  1. curl -X DELETE \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"id__in":["5c263d739a557716c96c6dc6","5c263d689a557718706c6e37"]}' \
  6. https://{{服务器域名}}/hserve/v2.2/uploaded-file/

状态码说明

204 删除成功

视频截图

接口

POST /hserve/v1/media/video-snapshot/

请求参数说明

参数 类型 必填 说明
source string Y 视频文件的 id
save_as string Y 截图保存的文件名
point string Y 截图时间格式,格式:HH:MM:SS
category_id string N 文件所属类别 ID
random_file_link boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true
size string N 截图尺寸,格式为 宽 x 高,默认是视频尺寸
format string N 截图格式,可选值为 jpg,png, webp, 默认根据 save_as 的后缀生成

返回参数

参数 类型 说明
created_at integer 创建时间 (格式为 unix 时间戳)
path string 上传成功后的访问地址 URL
created_by integer 创建者 id
mime_type string mime_type 类型
media_type string 媒体类型
size integer 文件大小
name string 文件名
status string 文件状态
reference object 引用
cdn_path string 文件在 CDN 中的相对路径
updated_at integer 更新时间 (格式为 unix 时间戳)
categories string 文件所属类别
id string 本条记录 ID

请求示例

  1. curl -X POST \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"source": "5cc577ec1466ec1a1b3f65bc", "save_as": "abc.png", "point": "00:00:10"}' \
  6. https://{{服务器域名}}/hserve/v1/media/video-snapshot/

返回示例

  1. {
  2. "status": "success",
  3. "id": "5c4a6dcc20fa9c2e054c6c3b",
  4. "created_at": 1548381644,
  5. "updated_at": 1548381644,
  6. "media_type": "image",
  7. "mime_type": "image/png",
  8. "size": 1122460,
  9. "reference": {},
  10. "name": "1-25-test.png",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqnUzZx1gNpp78.png",
  12. "cdn_path": "1gmqnUzZx1gNpp78.png",
  13. "categories": [
  14. {
  15. "id": "5a377bb009a8054139faafed",
  16. "parent": null,
  17. "name": "图片"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 截图成功

400 参数错误

404 文件不存在

M3U8 视频拼接

接口

POST /hserve/v1/media/m3u8-concat/

请求参数说明

参数 类型 必填 说明
m3u8s array Y 视频文件的 id 列表,按请求的顺序进行拼接
save_as string Y 截图保存的文件名
category_id string N 文件所属类别 ID
random_file_link boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true

返回参数

参数 类型 说明
created_at integer 创建时间 (格式为 unix 时间戳)
path string 上传成功后的访问地址 URL
created_by integer 创建者 id
mime_type string mime_type 类型
media_type string 媒体类型
size integer 文件大小
name string 文件名
status string 文件状态
reference object 引用
cdn_path string 文件在 CDN 中的相对路径
updated_at integer 更新时间 (格式为 unix 时间戳)
categories string 文件所属类别
id string 本条记录 ID

请求示例

  1. curl -X POST \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"m3u8s": ["5c453c7cfe10833f3178479e", "5c452bebfe10832bf97846c9"], "save_as": "abc.m3u8", "category_id": "5a377bcb09a8054139faaff1"}' \
  6. https://{{服务器域名}}/hserve/v1/media/m3u8-concat/

返回示例

  1. {
  2. "status": "pending",
  3. "id": "5c4a699820fa9c27f14c6ddd",
  4. "created_at": 1548380568,
  5. "updated_at": 1548380568,
  6. "media_type": "other",
  7. "mime_type": null,
  8. "size": 0,
  9. "reference": {},
  10. "name": "1-25-test.m3u8",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqW8egmWLqY4Q1.m3u8",
  12. "cdn_path": "1gmqW8egmWLqY4Q1.m3u8",
  13. "categories": [
  14. {
  15. "id": "5a377bcb09a8054139faaff1",
  16. "parent": null,
  17. "name": "视频"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 成功

400 参数错误

404 文件不存在

M3U8 视频剪辑

接口

POST /hserve/v1/media/video-clip/

请求参数说明

参数 类型 必填 说明
m3u8 string Y 视频文件的 id
save_as string Y 截图保存的文件名
category_id string N 文件所属类别 ID
random_file_link boolean N 是否使用随机字符串作为文件的下载地址,不随机可能会覆盖之前的文件,默认为 true
include array N 包含某段内容的开始结束时间,单位是秒。当 index 为 false 时,为开始结束分片序号
exclude array N 不包含某段内容的开始结束时间,单位是秒。当 index 为 false 时,为开始结束分片序号
index boolean N include 或者 exclude 中的值是否为 ts 分片序号,默认为 false

返回参数

参数 类型 说明
created_at integer 创建时间 (格式为 unix 时间戳)
path string 上传成功后的访问地址 URL
created_by integer 创建者 id
mime_type string mime_type 类型
media_type string 媒体类型
size integer 文件大小
name string 文件名
status string 文件状态
reference object 引用
cdn_path string 文件在 CDN 中的相对路径
updated_at integer 更新时间 (格式为 unix 时间戳)
categories string 文件所属类别
id string 本条记录 ID

请求示例

  1. curl -X POST \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"m3u8s": "5c452bebfe10832bf97846c9", "save_as": "abc.m3u8", "category_id": "5a377bcb09a8054139faaff1", "include": [0, 5]}' \
  6. https://{{服务器域名}}/hserve/v1/media/m3u8-clip/

返回示例

  1. {
  2. "status": "pending",
  3. "id": "5c4a685520fa9c27f14c6d48",
  4. "created_at": 1548380245,
  5. "updated_at": 1548380245,
  6. "media_type": "other",
  7. "mime_type": null,
  8. "size": 0,
  9. "reference": {},
  10. "name": "1-25-test.m3u8",
  11. "path": "https://cloud-minapp-7894.cloud.ifanrusercontent.com/1gmqQuVchCjctKhe.m3u8",
  12. "cdn_path": "1gmqQuVchCjctKhe.m3u8",
  13. "categories": [
  14. {
  15. "id": "5a377bcb09a8054139faaff1",
  16. "parent": null,
  17. "name": "视频"
  18. }
  19. ],
  20. "created_by": 2176
  21. }

状态码说明

200 成功

400 参数错误

404 文件不存在

M3U8 时长和分片信息

接口

POST /hserve/v1/media/m3u8-meta/

请求参数说明

参数 类型 必填 说明
m3u8 string Y 视频文件的 id

返回参数

res:

参数 类型 说明
status_code integer 状态码
message string 返回信息
meta object 详见以下

meta 参数说明:

参数 类型 说明
duartion integer m3u8 时长
points array 时间点

请求示例

  1. curl -X POST \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"m3u8s": "5c452bebfe10832bf97846c9"}' \
  6. https://{{服务器域名}}/hserve/v1/media/m3u8-meta/

返回示例

  1. {
  2. "message": "ok",
  3. "status_code": 200,
  4. "meta": {
  5. "duration": 1769.2619999999997,
  6. "points": [
  7. 20.44,
  8. 40,
  9. 60.92,
  10. 80.68,
  11. 100.16000000000001,
  12. 120.08000000000001,
  13. 1581.5839999999998,
  14. 1600.9429999999998,
  15. 1620.9429999999998,
  16. 1640.9429999999998,
  17. 1660.6629999999998,
  18. 1680.6629999999998,
  19. 1700.6629999999998,
  20. 1720.6629999999998,
  21. 1740.6629999999998,
  22. 1760.6629999999998,
  23. 1769.2619999999997
  24. ]
  25. }
  26. }

状态码说明

200 成功

400 参数错误

404 文件不存在

音视频原信息

接口

POST /hserve/v1/media/audio-video-meta/

请求参数说明

参数 类型 必填 说明
source string Y 文件的 id

返回参数

参数 类型 说明
format object 音视频格式信息,详见以下
streams array stream 列表,详见以下

format 参数说明:

参数 类型 说明
bitrate integer 比特率
duration integer 时长
format string 容器格式
fullname string 容器格式全称

streams 参数说明:

参数 类型 说明
index integer 表示第几路流
type string 一般情况下, video 或 audio
bitrate integer 流码率
codec string 流编码
codec_desc string 流编码说明
duration integer 流时长
video_fps integer (视频流)视频帧数
video_height integer (视频流)视频高度
video_width integer (视频流)视频宽度
audio_channels integer (音频流)音频通道数
audio_samplerate integer (音频流)音频采样率

请求示例

  1. curl -X POST \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"source": "5cc577ec1466ec1a1b3f65bc"}' \
  6. https://cloud.minapp.com/hserve/v1/media/audio-video-meta/

返回示例

  1. {
  2. "format": {
  3. "format": "mov,mp4,m4a,3gp,3g2,mj2",
  4. "filesize": 91427419,
  5. "duration": 43.451667,
  6. "fullname": "QuickTime / MOV",
  7. "bitrate": 16832941
  8. },
  9. "streams": [
  10. {
  11. "index": 0,
  12. "duration": 43.451667,
  13. "bitrate": 16762715,
  14. "video_fps": 24,
  15. "codec_desc": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
  16. "metadata": {
  17. "creation_time": "2016-01-17T02:58:26.000000Z",
  18. "encoder": "H.264",
  19. "language": "und",
  20. "rotate": "90",
  21. "handler_name": "Core Media Data Handler"
  22. },
  23. "video_height": 1080,
  24. "video_width": 1920,
  25. "type": "video",
  26. "codec": "h264"
  27. },
  28. {
  29. "index": 1,
  30. "duration": 43.451678,
  31. "bitrate": 62934,
  32. "codec_desc": "AAC (Advanced Audio Coding)",
  33. "metadata": {
  34. "creation_time": "2016-01-17T02:58:26.000000Z",
  35. "language": "und",
  36. "handler_name": "Core Media Data Handler"
  37. },
  38. "audio_samplerate": 44100,
  39. "audio_channels": 1,
  40. "type": "audio",
  41. "codec": "aac"
  42. }
  43. ]
  44. }

状态码说明

200 成功

400 参数错误

404 文件不存在

获取文件详情 v1.3

接口

GET /hserve/v2.2/uploaded-file/:file_id/

其中 :file_id 需替换为你的文件 ID

请求示例

  1. curl -X GET \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/uploaded-file/5cac3d2299ecae0c9e8aa3e6/

返回示例

  1. {
  2. "category": [
  3. {
  4. "id": "5cac3d2299ecae0c9e8aa3e6",
  5. "name": "Category",
  6. }
  7. ],
  8. "created_at": 1511762369,
  9. "id": "5cac3d2299ecae0c9e8aa3e6",
  10. "mime_type": "image/png",
  11. "name": "box_close.png",
  12. "path": "https://cloud-minapp-287.cloud.ifanrusercontent.com/1eJCS1MFGdvaaBoV.png",
  13. "size": 3652,
  14. }

获取文件列表 v1.3

接口

GET /hserve/v2.2/uploaded-file/

参数说明

参数 类型 必填 说明
order_by string Y 排序(支持 created_at 进行排序)
limit integer N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
offset integer N 设置返回资源的起始偏移值,默认为 0

请求示例

  1. curl -X GET \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -G \
  6. --data-urlencode "order_by=-created_at" \
  7. https://{{服务器域名}}/hserve/v2.2/uploaded-file/

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 5
  8. },
  9. "objects": [
  10. {
  11. "category": null,
  12. "created_at": 1546008508,
  13. "id": "5cac3d2299ecae0c9e8aa3e6",
  14. "mime_type": "image/jpeg",
  15. "name": "test.jpeg",
  16. "path": "https://cloud-minapp-18630.cloud.ifanrusercontent.com/1gctR6qybW3irhEo.jpeg",
  17. "size": 27273
  18. },
  19. ......
  20. ]
  21. }

删除文件 v1.3

接口

DELETE https://{{服务器域名}}/hserve/v2.2/uploaded-file/:file_id/

其中 :file_id 需替换为你的文件 ID

请求示例

  1. curl -X DELETE \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. https://{{服务器域名}}/hserve/v2.2/uploaded-file/5a1ba9c1fff1d651135e5ff1/

状态码说明

204 删除成功

批量删除文件 v1.3

接口

DELETE /hserve/v2.2/uploaded-file/

提交参数

id__in 包含多个文件 ID, ID 之间通过 , 分隔

请求示例

  1. curl -X DELETE \
  2. -H "X-Hydrogen-Client-ID: [[client_id]]" \
  3. -H "Authorization: Hydrogen-r1 {{AccessToken}}" \
  4. -H "Content-Type: application/json" \
  5. -d '{"id__in":["5c263d739a557716c96c6dc6","5c263d689a557718706c6e37"]}' \
  6. https://{{服务器域名}}/hserve/v2.2/uploaded-file/

状态码说明

204 删除成功