我尝试使用谷歌的应用程序引擎(Java)将文件上传到Amazon S3,但我并没有得到太多的帮助。首先,我从来没有做过任何REST编程,也没有做过GAE。
我已经查阅了S3的文档,并提出了以下代码。我走的路对吗?
final URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
final URL url = new URL("http", AWS_BUCKET+".s3.amazonaws.com/myFile.jpg", "");
final HTTPRequest request = new HTTPRequest(url, HTTPMethod.PUT, followRedirects());
request.addHeader(new HTTPHeader("Content-Type", contentType));
request.addHeader(new HTTPHeader("Content-Length", Integer.toString(pictureBytes.length)));
request.addHeader(new HTTPHeader("Expect", "100-continue"));
request.addHeader(new HTTPHeader("Authorization", "AWS "+AWS_ACCESS_KEY+":"+AWS_SECRET_KEY));
request.setPayload(pictureBytes);
urlFetchService.fetch(request);
当我运行上面的代码时,我得到
Entity enclosing requests cannot be redirected without user intervention
作为错误信息。
提前感谢您提供任何提示/提示/指针/URL/解决方案:)
干杯
丰富的