자바 ucloud storage 사용하기 (붙여넣기)

  다른 뜻에 대해서는 자바 ucloud storage 사용하기 (메이븐) 문서를 참조하십시오.

1 개요[ | ]

자바 ucloud storage 사용
  • 소스코드 폴더를 붙여넣는 방식에 대해 설명함

2 사전작업[ | ]

  • ucloud biz 회원가입
  • ucloud storage 상품신청

3 SDK 설정[ | ]

  • https://openapi.olleh.com 접속, 회원가입, 로그인
  • OpenAPI --- ucloud biz --- Storage API --- [SDK 다운로드] 클릭하여 ucloudstorage-sdk.zip 다운로드
  • ucloudstorage-sdk.zip 압축해제
  • 압축해제된 src/com 폴더를 스프링부트 프로젝트의 src/main/java 폴더에 드래그
  • (O) Copy files and folders --- [OK]
  • "Do you wish to overwrite?" --- [No]
  • pom.xml에 추가
<dependency>
	<groupId>org.apache.httpcomponents</groupId>
	<artifactId>httpclient</artifactId>
</dependency>
<dependency>
	<groupId>org.apache.commons</groupId>
	<artifactId>commons-lang3</artifactId>
	<version>3.3.2</version>
</dependency>

4 예제 코드[ | ]

  • 컨테이너(파일박스) 목록을 확인할 수 있는 예제코드
@RestController
public class MyController {

	@RequestMapping("/")
	private String home() throws IOException, HttpException {
		String email = "유클라우드액세스키아이디"; // testuser@example.com
		String secret = "유클라우드스토리지시크릿키"; // MSX2Tzu4YZDnYBH5Noq2QenqUWZaQlE0
		String endpoint = "https://ssproxy.ucloudbiz.olleh.com/auth/v1.0";
		int timeout = 10000;

		FilesClientExt client = new FilesClientExt(email, secret, endpoint, timeout);
		if( !client.login() ) return "로그인 실패";

		String result = "";
		List<FilesContainer> containers = client.listContainers();
		for( FilesContainer container: containers ) {
			result += container.getName() + "<br>";
		}
		return result;
	}
}

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}