# 文件

# 即时上传文件

用于文件大小不超过 10 MB,确保可以在一个 HTTP 请求中完成的场景

# 请求 URL:

  • http://host:port/heycloud/api/io/file/instantUpload

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
dir String - 文件目录

# 请求示例:

POST http://host:port/heycloud/api/io/file/instantUpload?dir=foo/bar
     <multipart/form-data>
       file: <file-data>

# 正确响应示例:

{
  "result": {
    "id": "040d948f53418503a37402111d58644e",
    "size": 4194304,
    "createdAt": "2021-08-29T01:22:40.767Z",
    "updatedAt": "2021-08-29T01:22:40.767Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 创建文件记录

用于后续上传文件切片并生成真实文件

# 请求 URL:

  • http://host:port/heycloud/api/io/file/create

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
dir String "" 文件目录
name String - 文件名
hash String - 文件的 MD5 Hash 值,相同的 Hash 代表文件内容相同,如果指定了 skipCheckHash 则可以自行维护一个代表文件内容变化的字符串
chunks String - 文件切片的 MD5 Hash 值列表
skipCheckHash Boolean - 合并分片后跳过校验文件 Hash 值,对于超大文件可以通过容忍可能的文件错误来提升效率

# 请求示例:

POST http://host:port/heycloud/api/io/file/create

{
  "dir": "dir-name/sub-dir",
  "name": "file-name.ext",
  "hash": "xxxxxxx",
  "chunks": ["..."],
  "skipCheckHash": true,
}

# 正确响应示例:

{
  "result": {
    "id": "040d948f53418503a37402111d58644e", //文件ID
    "createdAt": "2021-02-04T08:48:04.040Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 获取文件信息

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 文件 ID

# 请求示例:

GET http://host:port/heycloud/api/io/file/xxxxx

# 正确响应示例:

文件正在上传的响应

{
  "result": {
    "uploading": {
      "chunks": ["..."], //文件切片的 hash 值列表
      "uploadedChunks": ["..."], //已上传的切片的 hash 值列表
      "createdAt": "2021-03-09T10:25:39.869Z"
    }
  }
}

文件已上传成功的响应:

{
  "result": {
    "id": "5c17ed0a99a0b40f43662315cafb3560", //文件ID
    "createdAt": "2021-03-09T10:25:47.313Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 上传文件切片

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId/:chunkHash/upload

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 所属文件 ID
chunkHash String - 切片文件 Hash 值

# 请求示例:

POST http://host:port/heycloud/api/io/file/:fileId/:chunkHash/upload
     <multipart/form-data>
       file: <file-data>

# 正确响应示例:

{
  "result": {
    "size": 4194304, //切片大小
    "createdAt": "2021-08-29T01:22:40.767Z",
    "updatedAt": "2021-08-29T01:22:40.767Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 合并文件分片

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId/merge

# 请求方式:

  • POST

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 文件 ID

# 请求示例:

POST http://host:port/heycloud/api/io/file/xxxxx/merge

# 正确响应示例:

{
  "result": {
    "fileId": "040d948f53418503a37402111d58644e", //文件 ID
    "notifyAt": "2021-02-04T08:48:05.264Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 删除文件

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId

# 请求方式:

  • DELETE

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 所属文件 ID

# 请求示例:

DELETE http://host:port/heycloud/api/io/file/xxxxx

# 正确响应示例:

{
  "result": {
    "id": "040d948f53418503a37402111d58644e",
    "deletedAt": "2021-02-04T08:48:05.264Z"
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 获取 CSV 文件的信息

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId/exploreCsv

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 探索的文件 ID
encoding String - 手动指定编码,如不指定则自动检测编码

# 请求示例:

GET http://host:port/heycloud/api/io/file/xxxxx/exploreCsv?encoding=GBK

# 正确响应示例:

{
  "result": {
    "samples": [["id,name,x,y"]],
    "size": 102
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 获取 Excel 文件的信息

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId/exploreExcel

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 探索的文件 ID

# 请求示例:

GET http://host:port/heycloud/api/io/file/xxxxx/exploreExcel

# 正确响应示例:

{
  "result": {
    "sheets": {
      "sheet1": [
        ["id", "x", "y", "name", "日期(年/月/日)", "时间(时:分:秒)", "日期时间", "是/否"],
        ["0", "117.4483663", "29.1321093", "名称0", "5/11/20", "14:30:00", "5/11/20 14:30", "TRUE"]
      ]
    },
    "size": 102
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}

# 获取矢量数据的信息

# 请求 URL:

  • http://host:port/heycloud/api/io/file/:fileId/exploreFeatureLayer

# 请求方式:

  • GET

# 请求 Header:

字段 类型 是否必选 说明
x-heycloud-admin-session String 通过 session 提供管理权限
x-heycloud-account-id String 帐号的唯一标识符

# 请求参数:

参数名称 类型 是否必须 默认值 说明
fileId String - 探索的文件 ID
encoding String - 手动指定编码,如不指定则自动检测编码,指定编码只对 Shapefile 和 DXF 数据有效

# 请求示例:

GET http://host:port/heycloud/api/io/file/xxxxx/exploreFeatureLayer?encoding=GBK

# 正确响应示例:

{
  "result": {
    "size": 1020,
    "layers": [
      {
        "layerId": 0,
        "layerName": " sixOut",
        "samples": [
          {
            "type": "Feature",
            "geometry": "{
              \"type\": \"Point\",
              \"coordinates\": [ 107.022628784179688, 33.074281720636122 ]
            }",
            "properties": { "count": 5, "name": "汉中" }
          }
        ]
      }
    ]
  }
}

# 错误响应示例:

{
  "error": "Error",
  "message": "错误信息"
}