我想将 30MB 到 2GB 的大型视频文件上传到具有访问该文件的外部 URL 的 blob 存储。
到目前为止,我尝试过这样的事情,但它不适用于大文件,我认为是因为 32MB 的限制:
//InputStream is = new URL(getUrlThumbnailFullSize(wistiaResponse)).openStream();
HttpURLConnection con = (HttpURLConnection) new URL("URL of the file here").openConnection();
con.setConnectTimeout(0);
con.connect();
InputStream is = con.getInputStream();
//create file service to upload the video to the blob store
FileService fileService = FileServiceFactory.getFileService();
//create the App Engine File; assign MIME type and name
AppEngineFile file = fileService.createNewBlobFile("content type here", "file name here");
//lock when uploading file
boolean lock = true;
//open channel
FileWriteChannel writeChannel = fileService.openWriteChannel(file, lock);
//upload file
writeChannel.write(ByteBuffer.wrap(IOUtils.toByteArray(is)));
writeChannel.closeFinally();
//release the lock
lock = false;
//get blob key
BlobKey blobKey = FileServiceFactory.getFileService().getBlobKey(file);
但我有以下堆栈跟踪:
严重:com.google.appengine.api.urlfetch.ResponseTooLargeException:来自 url http://embed.wistia.com/deliveries/a0f8dc8ed210b53152af601eb0af40d76cd2929f.bin的响应 太大了。在 com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:57) 在 com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417) 在 com.google .apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296) 在控制器.CtrlWistia.download(CtrlWistia.java:149) 在控制器.CtrlWistia.ajax(CtrlWistia.java:89) 在控制器。 CtrlAjax.main(CtrlAjax.java:66) at vidaao.AjaxServlet.doPost(AjaxServlet.java:37) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service (HttpServlet.java:717) 在 org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) 在 org.