목표는 대용량 파일 (비디오)을 업로드하고 공개 공유 URL을 얻는 것입니다.GAE - Google 클라우드 저장소 - 업로드 (ACL : 공개 읽기 및 공개 공유 URL 가져 오기)
매우 직설적 인 것처럼 보이지만 나는 문서화 작업에 들어가는 하루 이상을 보내고 그 샘플을 찾지 못했습니다.
제대로 작동하는 Google 스토어에 업로드하려면 다음 코드가 표시되지만 URL에 'public-read'옵션을 추가하고 싶습니다. 서블릿에서 jsp 또는 after에 업로드하기 전에. 내 서블릿에서 다음
<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
<%@ page import="com.google.appengine.api.blobstore.UploadOptions" %>
<%
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
String uploadUrl = blobstoreService.createUploadUrl("/ajax?act=user&act2=video_upload", UploadOptions.Builder.withGoogleStorageBucketName("vidaao"));
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Upload Page</title>
</head>
<body>
<h1>Upload v3</h1>
<form name="form1" id="form1" action="<% out.print(uploadUrl); %>" method="post" enctype="multipart/form-data" target="upload_iframe">
<input type="hidden" name="hiddenfield1" value="ok">
Files to upload:
<br/>
<input type="file" name="myFile">
<br/>
<button type="submit">Send</button>
</form>
<iframe id="upload_iframe" name="upload_iframe"></iframe>
</body>
</html>
어딘가에 리디렉션 URL은 blobkey
public String upload(HttpServletRequest req, HttpServletResponse res) throws Exception{
Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
BlobKey blobKey = blobs.get("myFile");
if (blobKey == null) {
throw new Exception("Error file not uploaded");
}
//TODO: HERE get the public shared url of the file
return " blob key = " + blobKey.getKeyString();
}
의 세대가 끝 그리고이 단계에서 난 경우 Google 클라우드 스토리지에 대한 공개 공유 URL을 가지고 싶습니다 있을 수있다. (서블릿을 통해 파일을 처리 할 수 없으므로 시간이 초과 될 수 있습니다)