GCS json ํŒŒ์ผ ์ฝ๊ธฐ

import com.google.cloud.storage.Blob;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import com.google.auth.oauth2.GoogleCredentials;

public class gcs_json_file_read{
	private static String PROJECT_ID = "your-project-id";
	private static String PATH_TO_JSON_KEY = "your-service-key";
	private static String BUCKET_NAME = "your-bucket-name";
	private static String OBJECT_NAME = "your-file-name";

public void main(String[] args) {
StorageOptions options = null;

	try {
		options = StorageOptions.newBuilder()
			.setProjectId(PROJECT_ID)
			.setCredentials(GoogleCredentials.fromStream(
			new FileInputStream(PATH_TO_JSON_KEY))).build();
	     } catch (Exception e){
			System.out.println(e);
	     }

	Storage storage = options.getService();
	Blob blob = storage.get(BUCKET_NAME, OBJECT_NAME);
	String test = new String(blob.getContent());

	System.out.println(test)
	}
}

๋Œ“๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ด๋ฉ”์ผ์€ ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ์ž…๋ ฅ์ฐฝ์€ * ๋กœ ํ‘œ์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค