--- title: "Java SDK" slug: "archivestorage-javasdk" tags: ["Archive Storage"] updated: 2026-09-17T09:17:55Z published: 2026-09-17T09:17:55Z canonical: "guide.ncloud-docs.com/archivestorage-javasdk" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Java SDK Available in Classic and VPC. This is an example of using NAVER Cloud Platform Archive Storage using openstack4j library. This guide is based on openstack4j 3.1.0 version. See [openstack4j](https://www.openstack4j.com/learn) for related documentation. ## Installation You can download the library directly or install it with Apache Maven. - **Library download** [openstack4j 3.1.0 version download](https://search.maven.org/remotecontent?filepath=org/pacesys/openstack4j/3.1.0/openstack4j-3.1.0.jar) - **Install with Apache Maven** ``` org.pacesys openstack4j 3.1.0 ``` ## Example The values​to be applied to `user`, `password`, in the example use the API authentication key information created on the NAVER Cloud Platform portal. In the API authentication key information, enter the Access Key ID in the value of `user` and the Secret Key in the value of `password`. `domainid`, `projectid` use the information in the pop-up window that appears when you click the **[Check API usage information]** button on the Archive Storage screen. Enter the domain ID in the value of `domainid` and the project ID value in the value of `projectid`. Note - For information on how to check the API authentication key information, see [Create and Check API Authentication Key](/docs/en/archivestorage-start#API%EC%9D%B8%EC%A6%9D%ED%82%A4%EC%83%9D%EC%84%B1%EB%B0%8F%ED%99%95%EC%9D%B8). - To check the project_id and domain_id information, please check [API Use Information](/docs/en/archivestorage-start#API%EC%9D%B4%EC%9A%A9%EC%A0%95%EB%B3%B4%ED%99%95%EC%9D%B8). ### Create Client Create an OS client with a token object created with authentication information. The client automatically renews the token when it becomes invalid or expires. Since token objects are shared in a multi-threaded environment, unnecessary authentication procedures can be reduced. Note All examples in this guide use a token object created with credentials. ``` final String endpoint = "https://kr.archive.ncloudstorage.com:5000/v3"; final String user = "ACCESS_KEY_ID"; final String password = "SECRET_KEY"; final String domainId = "DOMAIN_ID"; final String projectId = "PROJECT_ID"; Token token = OSFactory.builderV3() .endpoint(endpoint) .credentials(user, password, Identifier.byId(domainId)) .scopeToProject(Identifier.byId(projectId), Identifier.byId(domainId)) .authenticate() .token; OSClientV3 client = OSFactory.clientFromToken(token); ``` ``` // Spawn off a thread giving it the access myThreadExecutor.submit(new MyRunnableOrCallable(token)); // Example of the Runnable or other object invoked in a new thread public class MyRunnable implements Runnable { private OSClientV3 client; public MyRunnable(Access access) { client = OSFactory.clientFromToken(token); } public void run() { // can now use the client :) } } ``` ### View container (bucket) list Here's an example of how you can view a list of containers (buckets). ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageContainerService containerService = client.objectStorage().containers(); List containers = containerService.list(ContainerListOptions.create().limit(100)); for (SwiftContainer container : containers) { System.out.println(container); } ``` ### Create a container (bucket) Here's an example of how you can create a container (bucket). ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageContainerService containerService = client.objectStorage().containers(); String containerName = "sample-container"; // with metadata // X-Container-Meta-Test-Meta-Key: test-meta-value Map metadata = new HashMap<>(); metadata.put("test-meta-key", "test-meta-value"); ActionResponse response containerService.create(containerName, CreateUpdateContainerOptions.create().metadata(metadata)); System.out.println(response); ``` ### Delete container (bucket) Here's an example of how you can delete a container (bucket). ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageContainerService containerService = client.objectStorage().containers(); String containerName = "sample-container"; ActionResponse response = containerService.delete(containerName); System.out.println(response); ``` ### Upload object Here's an example of how you can upload an object. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-object.txt"; String contentType = "text/plain"; File file = new File("/tmp/sample-object.txt"); // with metadata // X-Object-Meta-Test-Meta-Key : test-meta-value Map metadata = new HashMap<>(); metadata.put("test-meta-key", "test-meta-value"); String etag = objectService.put(containerName, objectName, Payloads.create(file), ObjectPutOptions.create().contentType(contentType).metadata(metadata)); System.out.println(etag); ``` ### Create directory object Here's an example of how you can create a directory object. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageContainerService containerService = client.objectStorage().containers(); String containerName = "sample-container"; String directoryName = "sample-directory"; String etag = containerService.createPath(containerName, directoryName); System.out.println(etag); ``` ### View object list Here's an example of how you can view the object list. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String directoryName = "sample-directory"; // simple List objects = objectService.list(containerName); for (SwiftObject object : objects) { System.out.println(object); } // list for directory List objectsForDirectory = objectService.list(containerName, ObjectListOptions.create().path(directoryName)); for (SwiftObject object : objectsForDirectory) { System.out.println(object); } ``` ### Download object Here's an example of how you can download an object. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-object.txt"; String downloadPath = "/tmp/sample-object.txt"; DLPayload payload = objectService.download(containerName, objectName); File file = new File(downloadPath); payload.writeToFile(file); ``` ### Delete object Here's an example of how you can delete an object. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-object.txt"; ActionResponse response = objectService.delete(containerName, objectName); System.out.println(response); ``` ### Uploading a large file(SLO) Here's an example of how you can upload an object using the SLO method. ``` OSClientV3 client = OSFactory.clientFromToken(getToken()); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-big-file.mp4"; String contentType = "video/mp4"; String segmentContainerName = "segment-container"; String segmentPrefix = "segments-for-sample-big-file.mp4/segment-"; List> segmentInfoList = new ArrayList<>(); File file = new File("/tmp/sample.mp4"); FileInputStream fs = new FileInputStream(file); int bufferSize = 1024 * 1024 * 10; // 10MB byte[] buffer = new byte[bufferSize]; int segmentNo = 1; int bytesRead; while ((bytesRead = fs.read(buffer)) != -1) { Map segmentInfo = new HashMap<>(); InputStreamPayload payload = new InputStreamPayload(new ByteArrayInputStream(buffer, 0, bytesRead)); String etag = objectService.put(segmentContainerName, segmentPrefix + segmentNo, payload); segmentInfo.put("path", "/" + segmentContainerName + "/" + segmentPrefix + segmentNo); segmentInfo.put("etag", etag); segmentInfo.put("size_bytes", bytesRead); segmentInfoList.add(segmentInfo); segmentNo++; } fs.close(); String manifest = new ObjectMapper().writeValueAsString(segmentInfoList); String etag = objectService.put(containerName, objectName, Payloads.create(new ByteArrayInputStream(manifest.getBytes())), ObjectPutOptions.create().queryParam("multipart-manifest", "put").contentType(contentType)); System.out.println(etag); ``` ### View large file segments (SLO) Here's an example of how you can view large file segments. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-big-file.mp4"; ObjectListOptions options = ObjectListOptions.create(); options.getOptions().put("multipart-manifest", "get"); List objects = objectService.list(containerName + "/" + objectName, options); for (SwiftObject object : objects) { System.out.println(object); } ``` ### Delete large file (SLO) Here's an example of how you can delete large files. ``` OSClientV3 client = OSFactory.clientFromToken(token); ObjectStorageObjectService objectService = client.objectStorage().objects(); String containerName = "sample-container"; String objectName = "sample-big-file.mp4"; ActionResponse response = objectService.delete(ObjectLocation.create(containerName, objectName), ObjectDeleteOptions.create().queryParam("multipart-manifest", "delete")); System.out.println(response); ```