阅读本文,您可以获取 Java SDK 资源管理的接口调用示例,实现快速开发。
调用接口前,请先完成 Java SDK 的安装及初始化操作。
本节为您介绍资源管理相关接口的功能和调用示例。
您可以调用 UpdateImageFileKey 接口通过指定源文件的 storekey 来对指定文件进行重命名操作。详细的参数说明可参见 UpdateImageFileKey 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class UpdateImageFileKeyExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); UpdateImageFileKeyQuery query = new UpdateImageFileKeyQuery(); UpdateImageFileKeyBody body = new UpdateImageFileKeyBody(); try { UpdateImageFileKeyRes resp = service.updateImageFileKey(query, body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetImageUploadFile 接口指定服务 ID 以及已上传的文件 Uri,来获取上传文件的详细信息。详细的参数说明可参见 GetImageUploadFile 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetImageUploadFileExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetImageUploadFileQuery query = new GetImageUploadFileQuery(); try { GetImageUploadFileRes resp = service.getImageUploadFile(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetImageStorageFiles 接口列举并返回服务对应存储下的全量资源,并按照 Key 的字典序返回。详细的参数说明可参见 GetImageStorageFiles 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetImageStorageFilesExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetImageStorageFilesQuery query = new GetImageStorageFilesQuery(); try { GetImageStorageFilesRes resp = service.getImageStorageFiles(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetImageUploadFiles 接口获取当前服务下全部的上传文件信息。详细的参数说明可参见 GetImageUploadFiles 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetImageUploadFilesExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetImageUploadFilesQuery query = new GetImageUploadFilesQuery(); try { GetImageUploadFilesRes resp = service.getImageUploadFiles(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 DeleteImageUploadFiles 接口删除指定的文件。详细的参数说明可参见 DeleteImageUploadFiles 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class DeleteImageUploadFilesExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); DeleteImageUploadFilesQuery query = new DeleteImageUploadFilesQuery(); DeleteImageUploadFilesBody body = new DeleteImageUploadFilesBody(); try { DeleteImageUploadFilesRes resp = service.deleteImageUploadFiles(query, body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 PreviewImageUploadFile 接口获取指定文件的详细信息。详细的参数说明可参见 PreviewImageUploadFile 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class PreviewImageUploadFileExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); PreviewImageUploadFileQuery query = new PreviewImageUploadFileQuery(); try { PreviewImageUploadFileRes resp = service.previewImageUploadFile(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetResourceURL 接口获取指定服务即域名的资源地址。详细的参数说明可参见 GetResourceURL 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetResourceURLExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetResourceURLQuery query = new GetResourceURLQuery(); try { GetResourceURLRes resp = service.getResourceURL(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 FetchImageUrl 接口对待迁移文件资源进行抓取和上传,并获取迁移后文件 URI。详细的参数说明可参见 FetchImageUrl 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class FetchImageUrlExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); FetchImageUrlBody body = new FetchImageUrlBody(); try { FetchImageUrlRes resp = service.fetchImageUrl(body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetUrlFetchTask 接口通过异步 Fetch 任务 ID,获取异步任务详情。详细的参数说明可参见 GetUrlFetchTask 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetUrlFetchTaskExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetUrlFetchTaskQuery query = new GetUrlFetchTaskQuery(); try { GetUrlFetchTaskRes resp = service.getUrlFetchTask(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 CreateImageCompressTask 接口指定压缩文件/文件夹及其他配置创建异步压缩任务,系统将执行压缩打包处理并将压缩包存储至指定服务内。详细的参数说明可参见 CreateImageCompressTask 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class CreateImageCompressTaskExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); CreateImageCompressTaskQuery query = new CreateImageCompressTaskQuery(); CreateImageCompressTaskBody body = new CreateImageCompressTaskBody(); try { CreateImageCompressTaskRes resp = service.createImageCompressTask(query, body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 GetCompressTaskInfo 接口获取压缩任务详情。详细的参数说明可参见 GetCompressTaskInfo 接口文档。
接口调用示例如下所示。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class GetCompressTaskInfoExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); GetCompressTaskInfoQuery query = new GetCompressTaskInfoQuery(); try { GetCompressTaskInfoRes resp = service.getCompressTaskInfo(query); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 UpdateImageResourceStatus 接口修改指定服务下资源的封禁状态。详细的参数说明可参见 UpdateImageResourceStatus 接口文档。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class UpdateImageResourceStatusExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); UpdateImageResourceStatusQuery query = new UpdateImageResourceStatusQuery(); UpdateImageResourceStatusBody body = new UpdateImageResourceStatusBody(); try { UpdateImageResourceStatusRes resp = service.updateImageResourceStatus(query, body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
您可以调用 CreateImageFromUri 接口源服务内的存储资源,复制到目标服务中。详细的参数说明可参见 CreateImageFromUri 接口文档。
package com.volcengine.example.imagex.v2.api; import com.volcengine.model.imagex.v2.*; import com.volcengine.service.imagex.v2.ImagexService; public class CreateImageFromUriExample { public static void main(String[] args) { ImagexService service = ImagexService.getInstance(); service.setAccessKey("ak"); service.setSecretKey("sk"); CreateImageFromUriQuery query = new CreateImageFromUriQuery(); CreateImageFromUriBody body = new CreateImageFromUriBody(); try { CreateImageFromUriRes resp = service.createImageFromUri(query, body); System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }