I have this simple piece of code that is trying to upload a file to Amazon S3 through a proxy. This is the code:
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));
However, this is the error I received from running the program:
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
I am using the latest aws 1.3.8 sdk from amazon. The proxy server is configured on another computer next to me, and it's just a Javascript proxy (http://www.catonmat.net/http-proxy-in-nodejs/)
I canβt understand why. Can anyone help me please?
source share