我有这段简单的代码,它试图通过代理将文件上传到 Amazon S3。这是代码:
BasicAWSCredentials basicCred = new BasicAWSCredentials("my_access_key", "my_secret_key");
ClientConfiguration clientCfg = new ClientConfiguration();
clientCfg.setProtocol(Protocol.HTTP);
//setup proxy connection:
clientCfg.setProxyHost("192.168.2.12");
clientCfg.setProxyPort(80);
AmazonS3 s3 = new AmazonS3Client(basicCred, clientCfg);
String bucketName = "mybucket";
String key = "/test/Capture.JPG";
File file = new File("d:/Test_Data/Capture.JPG");
System.out.println("Uploading a new object to S3 from a file");
s3.putObject(new PutObjectRequest(bucketName, key, file));
然而,这是我从运行程序中得到的错误:
Exception in thread "main" java.lang.NullPointerException
at com.amazonaws.util.BinaryUtils.fromHex(BinaryUtils.java:69)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1066)
at javaapplication8.JavaApplication8.main(JavaApplication8.java:48)
Java Result: 1
我正在使用来自亚马逊的最新 aws 1.3.8 sdk。代理设置在我旁边的另一台 PC 上,它只是一个简单的 Javascript 代理 (http://www.catonmat.net/http-proxy-in-nodejs/)
我不知道为什么。有人可以帮助我吗?