# HCP API元件

### Hitachi Content Platform

此為Hitachi提供之檔案放置雲端平台之解決方案，參考API說明書，撰寫該元件之共用元件建立

提供以下服務

* 新增
* 刪除
* 更新
* 查詢

#### 查詢範例

```
@Test
void test_get_file_then_HcpGet_then_file() {

   HcpGet hcpDownloadInfo = new HcpGet();
   String restPath = HcpUtil.toRestPath("x.pdf", "1", "2", "3", "4");
   hcpDownloadInfo.setPath(restPath);

   GetHcpInfo execute;
   try {
      execute = hcpService.execute(hcpDownloadInfo);
      String size = execute.getSize();
      assertThat(size).isNotBlank();
   } catch (HcpCodeExcepton e) {
      fail("");
   }

}
```

#### 刪除範例

```
@Test
void test_delet_file_then_HcpGet_then_ok() {
   HcpDelete cmd = new HcpDelete();
   String restPath = HcpUtil.toRestPath("x.pdf", "1", "2", "3", "4");
   cmd.setPath(restPath);

   try {
      BaseHcpInfo execute = hcpService.execute(cmd);
   } catch (HcpCodeExcepton e) {
      e.printStackTrace();
   }

}
```

新增範例

```
@Test
void test_put_file_then_put_then_ok() throws IOException, URISyntaxException {

   String restPath = HcpUtil.toRestPath("x.pdf", "1", "2", "3", "4");
   URL resource = HcpServiceTest.class.getClassLoader().getResource("test.zip");

   byte[] myByte = FileUtils.readFileToByteArray(new File(resource.toURI()));

   HcpPut cmd = new HcpPut(restPath, myByte);

   try {
      BaseHcpInfo execute = hcpService.execute(cmd);
      log.info("execute:{}", execute);
   } catch (HcpCodeExcepton e) {
      log.info("error code:{}", e.getCode(), e);
   }

}
```

#### maven設定

io.github.h8000572003 hcp 0.0.5

```
<dependency>
  <groupId>io.github.h8000572003</groupId>
  <artifactId>hcp-start</artifactId>
  <version>0.0.1</version>
</dependency>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andfood.gitbook.io/side-project/yuan-jian-she-ji/hcp-api-yuan-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
