文档中心 对象存储 文件解压缩

文件解压缩

更新时间:2023-09-26 17:50:03

该接口提供在云存储平台对压缩包进行解压缩的功能。解压缩后在云存储上默认生成一个list文件,文件内容包含解压缩后的文件信息。需要用户拥有wos:ProcessMedia权限,以及目标文件的putObject权限 ,如果解压缩还配置了删除源文件,还需要有deleteObject权限。

新建解压缩任务

请求语法

Post /key?decompression HTTP/1.1      
Host:Bucket.Endpoint
Date:Date
Authorization:Authorization
 
<?xml version="1.0" encoding="utf-8"?>
<Decompression xmlns="http://wcs.chinanetcenter.com/document">   
  <Config>
    <Param>
      <format>string</format>    
      <bucket>string</bucket>
      ...
    </Param> 
    <Output>
      <OutputBucket>string</OutputBucket> 
      <OutputKey>string</OutputKey>
    </Output>
  </Config> 
  <NotifyURL>string</NotifyURL> 
  <Force>int</Force> 
</Decompression>

请求参数

请求头部

仅使用公共请求头部。

请求主体

请求主体为如下的xml信息

元素名称 元素描述 是否必填
Decompression 定义解压缩处理配置列表。
类型:XML
子节点:Config、NotifyURL、Force
父节点:空
Config 定义解压缩处理操作。
类型:XML
子节点:Param、Output
父节点:Decompression
Param 定义解压缩处理的详细配置。
类型:XML
子节点:format,dir等。
父节点:Config
Output 定义输出文件的信息
类型:XML
子节点:OutputBucket、OutputKey
父节点:Config
OutputBucket 输出文件的空间名
类型:字符串
父节点:Output
OutputKey 输出文件的文件名,需要进行UrlEncode编码。
类型:字符串
父节点:Output
NotifyURL 处理结果通知接收URL,需要进行UrlEncode编码。
类型:字符串
父节点:Decompression
Force 是否强制执行数据处理。支持设置以下数值,默认缺省为0。
   0:指定的数据处理结果如果存在,返回文件已存在,不进行处理,避免重复处理浪费资源
  1:强制执行数据处理并覆盖已有文件
类型:整型
父节点:Decompression

响应语法

如果请求成功,则返回以下内容 :

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
Date: date
Server: WS-web-server
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DecompressionResult xmlns="http://wcs.chinanetcenter.com/document">
  <Succeed>
    <PersistentId>string</PersistentId>
 </Succeed>
</DecompressionResult>

响应头部

仅使用公共头部

响应元素

元素名称 元素描述
PersistentId 是解压缩处理的任务ID

示例

Post /test.zip?decompression HTTP/1.1      
Host:Bucket.Endpoint
Date:Date
Authorization:Authorization

<?xml version="1.0" encoding="utf-8"?>
<Decompression xmlns="http://wcs.chinanetcenter.com/document">   
  <Config> 
    <Param> 
      <format>zip</format>  
      <crush>0</crush> 
    </Param>  
    <Output> 
      <OutputBucket>excite</OutputBucket>  
      <OutputKey>test.list</OutputKey> 
    </Output> 
  </Config> 
</Decompression>


HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
Date: date
Server: WS-web-server
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DecompressionResult xmlns="http://wcs.chinanetcenter.com/document">
  <Succeed>
    <PersistentId>20500a49659******e088b1f736aa2a4</PersistentId>
 </Succeed>
</DecompressionResult>

查询解压缩任务

该接口提供在云存储上查询解压缩持久化处理的状态。需要用户拥有wos:GetProcessMediaStatus权限

请求语法

Get /?decompression&persistentId=<persistentId>    
Host:Bucket.Endpoint
Date:Date
Authorization:Authorization

请求参数

参数名称 是否必填 参数描述
persistentId 解压缩处理接口返回的persistentId。

请求头部

仅使用公共请求头部。

请求主体

响应语法

HTTP/1.1 StatusCode
Date: Date
Content-Type: type
Content-Length: length
Server: WS-web-server
 
<?xml version="1.0" encoding="utf-8"?>
<QueryDecompressionResult xmlns="https://wcs.chinanetcenter.com/document"> 
  <Id>string</Id> 
  <CreationTime>string</CreationTime> 
  <Input>
    <Bucket>string</Bucket> 
    <Key>string</Key> 
    <Size>int</Size>
  </Input> 
  <Item>
    <Cmd>string</Cmd> 
    <Code>int</Code> 
    <Desc>string</Desc> 
    <CostTime>int</CostTime> 
    <Error>string</Error> 
    <Output>
      <OutputBucket>string</OutputBucket> 
      <OutputKey>string</OutputKey>  
      <Size>int</Size> 
    </Output>
  </Item>
</QueryDecompressionResult>

响应头部

仅使用公共头部

示例

请求示例
Get /?decompression&persistentId=20500a496******b1f736aa2a4    
Host:Bucket.Endpoint
Date:Date
Authorization:Authorization

响应示例
HTTP/1.1 200 OK
Content-Type:application/xml
Content-Length:length
Date:date
Server: WS-web-server

<?xml version="1.0" encoding="utf-8"?>
<QueryDecompressionResult xmlns="https://wcs.chinanetcenter.com/document"> 
 <Id>20500a496******b1f736aa2a4</Id> 
  <CreationTime>2019-05-16T03:16:05Z</CreationTime> 
  <Input>
    <Bucket>sweet</Bucket> 
    <Key>happy%2Ftest.zip</Key> 
    <Size>1000</Size>
  </Input> 
  <Item>
    <Cmd>decompression/zip</Cmd> 
    <Code>3</Code> 
    <CostTime>0</CostTime> 
    <Desc>finish</Desc> 
    <Error>null</Error> 
    <Output>
      <OutputBucket>excite</OutputBucket> 
      <OutputKey>test.list</OutputKey> 
      <Size>2000</Size> 
    </Output>
  </Item>
</QueryDecompressionResult>

解压缩查询、通知数据说明

格式如下:

<?xml version="1.0" encoding="utf-8"?>
<NotifyBody xmlns="https://wcs.chinanetcenter.com/document"> 
  <Id>string</Id> 
  <CreatTime>string</CreatTime> 
  <Input>
    <Bucket>string</Bucket> 
    <Key>string</Key> 
    <Size>int</Size>
  </Input> 
  <Item>
    <Cmd>string</Cmd> 
    <Code>int</Code> 
    <Desc>string</Desc> 
    <CostTime>int</CostTime> 
    <Error>string</Error> 
    <Output>
      <OutputBucket>string</OutputBucket> 
      <OutputKey>string</OutputKey>  
      <Size>int</Size> 
      <Hash>string</Hash>
    </Output>
  </Item>
</NotifyBody>

参数说明:

column1 column2
NotifyBody 返回持久化处理结果
类型:XML
Id 持久化处理接口返回的persistentId
类型:字符串
父节点:NotifyBody
CreatTime 任务创建时间,格式为yyyymmddhhmmss。
类型:字符串
父节点:NotifyBody
Input 源文件的信息
类型:XML
父节点:NotifyBody
子节点:Bucket,Key,Size
Bucket 源文件的空间名
类型:字符串
父节点:Input
Key 源文件的文件名,需要进行UrlEncode编码
类型:字符串
父节点:Input
Size 源文件的大小
类型:整型
父节点:Input
Item 解压缩操作的状态信息
类型:XML
父节点:NotifyBody
子节点:Cmd、Code等
Cmd 操作命令(ops)
类型:字符串
父节点:Item
Code 处理结果状态码,2处理失败,3处理成功
类型:整型
父节点:Item
Desc 与状态码相应的详细描述
类型:字符串
父节点:Item
CostTime 持久化处理花费的时间,非特殊场景默认是0
类型:整型
父节点:Item
Error 如果处理失败,该字段列出具体原因
类型:字符串
父节点:Item
Output 处理后的文件信息
类型:XML
父节点:Item
OutputBucket 处理后文件的空间名
类型:字符串
父节点:Output
OutputKey 处理后的文件名,需要进行UrlEncode编码
类型:字符串
父节点:Output
Size 处理后的文件大小
类型:整型
父节点:Output
Hash 处理结果的hash值
类型:字符串
父节点:Output

解压缩参数详情

参数 是否必填 描述
bucket 解压文件到指定的空间。
crush 解压成功后的操作:
2-解压成功后删除压缩文件,不创建list文件
1-解压成功后删除压缩文件,保留list文件
0-解压成功后保留压缩文件,保留list文件
format 解压的文件格式,支持zip、tar、gzip、7z、rar
p 指定解压文件时的密码,为保证安全,需要进行RSA加密:
1、RSA密钥对由客户提供,并将公钥告知云存储。
prefix 解压文件到指定的具体路径,需要进行UrlEncode编码,默认以当前压缩包的目录进行解压缩
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!