Weirdly I updated the project libs and they came down (when you start a new project does it use old libs or something?) and the error has now changed to:
Error response: <?xml version="1.0" encoding="UTF-8"?> <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>8D202DD01F08C7AD</RequestId><HostId>OTi61ymlaENhFrgxAPCw76S6DcyNCorNr+RP6VAAP11VUplbRoBGIuK8WvrL8VSnVrqKlNfV94o=</HostId></Error> On 5 July 2017 at 22:12, Gareth Murfin <[email protected]> wrote: > > Swapped url to https://mybucket.s3.amazonaws.com > > and now getting this error, still progress :-)) Im sure I read about this > on stackvoerflow, the order thing, > > <?xml version="1.0" encoding="UTF-8"?> > <Error><Code>InvalidArgument</Code><Message>Bucket POST must contain a > field named 'key'. If it is specified, please check the order of the > fields.</Message><ArgumentName>key</ArgumentName><ArgumentValue></ > ArgumentValue><RequestId>B8AF949922CB80EF</RequestId><HostId> > Qws3NOeXsWpdBqZYTzw22b8glWfAPtlL986Auy2UfiZRk0Xul8NUP0626IiH > 5V+hACgHrUWkP94=</HostId></Error> > > > On Wednesday, July 5, 2017 at 9:02:29 PM UTC+8, Gareth Murfin wrote: >> >> just realised I have not authenticated to AWS in any way, thats probably >> the issue :) But I cant find any code snippets anywhere to actually do this >> ? Is there any AWS loggin code around I can see? Cheers, Gaz. >> >> On Wednesday, July 5, 2017 at 8:09:31 PM UTC+8, Gareth Murfin wrote: >>> >>> I also tried Shais code from stack oveflow, >>> >>> Button upload = new Button("Upload"); >>> hi.add(upload); >>> upload.addActionListener(e -> { >>> String file = Capture.capturePhoto(); >>> if(file != null) { >>> try { >>> String uniqueFileName = "Image" + System.currentTimeMillis() + >>> ".jpg"; >>> MultipartRequest rq = new MultipartRequest(); >>> rq.setUrl("https://s3.amazonaws.com/my-bucket/"); >>> rq.addArgument("key", uniqueFileName); >>> rq.addArgument("acl", "private"); >>> rq.addData("file", file, "image/jpeg"); >>> rq.setReadResponseForErrors(true); >>> NetworkManager.getInstance().addToQueueAndWait(rq); >>> if(rq.getResponseCode() != 200 && rq.getResponseCode() != 204) { >>> System.out.println("Error response: " + new >>> String(rq.getResponseData())); >>> } >>> ToastBar.showMessage("Upload completed", >>> FontImage.MATERIAL_INFO); >>> } catch(IOException err) { >>> Log.e(err); >>> } >>> }}); >>> >>> >>> >>> >>> this gives me the error >>> >>> java.io.IOException: Error writing to server >>> at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Ht >>> tpURLConnection.java:666) >>> at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Ht >>> tpURLConnection.java:678) >>> at sun.net.www.protocol.http.HttpURLConnection.getInputStream0( >>> HttpURLConnection.java:1534) >>> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(H >>> ttpURLConnection.java:1441) >>> at java.net.HttpURLConnection.getResponseCode(HttpURLConnection >>> .java:480) >>> at sun.net.www.protocol.https.HttpsURLConnectionImpl.getRespons >>> eCode(HttpsURLConnectionImpl.java:338) >>> at com.codename1.impl.javase.JavaSEPort.getResponseCode(JavaSEP >>> ort.java:6248) >>> at com.codename1.io.ConnectionRequest.performOperation(Connecti >>> onRequest.java:403) >>> at com.codename1.io.NetworkManager$NetworkThread.run( >>> NetworkManager.java:282) >>> at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176) >>> java.lang.NullPointerException >>> at java.lang.String.<init>(String.java:566) >>> at userclasses.StateMachine.initVars(StateMachine.java:56) >>> at generated.StateMachineBase.startApp(StateMachineBase.java:54) >>> at generated.StateMachineBase.<init>(StateMachineBase.java:31) >>> at generated.StateMachineBase.<init>(StateMachineBase.java:96) >>> at userclasses.StateMachine.<init>(StateMachine.java:26) >>> at com.norby.uploader.NorbyS3.start(NorbyS3.java:32) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce >>> ssorImpl.java:62) >>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe >>> thodAccessorImpl.java:43) >>> at java.lang.reflect.Method.invoke(Method.java:497) >>> at com.codename1.impl.javase.Executor$1$1.run(Executor.java:106) >>> at com.codename1.ui.Display.processSerialCalls(Display.java:1151) >>> at com.codename1.ui.Display.mainEDTLoop(Display.java:968) >>> at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120) >>> at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176) >>> Java Result: 1 >>> >>> On Wednesday, July 5, 2017 at 6:53:24 PM UTC+8, Gareth Murfin wrote: >>>> >>>> I found some code that is supposed to work from stack over flow for s3 >>>> upload (shown below). However I always get this error when I try it >>>> >>>> java.io.IOException: Error writing to server >>>> at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Ht >>>> tpURLConnection.java:666) >>>> at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Ht >>>> tpURLConnection.java:678) >>>> at sun.net.www.protocol.http.HttpURLConnection.getInputStream0( >>>> HttpURLConnection.java:1534) >>>> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(H >>>> ttpURLConnection.java:1441) >>>> at java.net.HttpURLConnection.getResponseCode(HttpURLConnection >>>> .java:480) >>>> at sun.net.www.protocol.https.HttpsURLConnectionImpl.getRespons >>>> eCode(HttpsURLConnectionImpl.java:338) >>>> at com.codename1.impl.javase.JavaSEPort.getResponseCode(JavaSEP >>>> ort.java:6248) >>>> at com.codename1.io.ConnectionRequest.performOperation(Connecti >>>> onRequest.java:403) >>>> at com.codename1.io.NetworkManager$NetworkThread.run( >>>> NetworkManager.java:282) >>>> at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176) >>>> >>>> >>>> private void doUpload() >>>> { >>>> try { >>>> String strImage = Capture.capturePhoto(); >>>> String s3Bucket = "https://usaeasygazy.s3.amazonaws.com"; >>>> //usa ones are easier no redirects? >>>> String fileName = "ARSE"; >>>> MultipartRequest rq = new MultipartRequest(); >>>> rq.setUrl(s3Bucket); >>>> rq.addArgumentNoEncoding("key", fileName); >>>> //rq.addArgument("acl", "public-read-write"); // here I >>>> give read-write access >>>> rq.addArgument("acl", "bucket-owner-full-control"); >>>> rq.addData("file", strImage, "image/jpeg"); >>>> >>>> _("add request to queue"); >>>> NetworkManager.getInstance().addToQueue(rq); >>>> _("done"); >>>> } catch (IOException ex) { >>>> _("ERROR DURING UPLOAD.! "+ex.getMessage()); >>>> } >>>> } >>>> >>> -- > You received this message because you are subscribed to a topic in the > Google Groups "CodenameOne Discussions" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/codenameone-discussions/pEPrG2d4IQw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > Visit this group at https://groups.google.com/ > group/codenameone-discussions. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/codenameone-discussions/769d0d0c-2f76-4dc0-b708- > b8e963a74127%40googlegroups.com > <https://groups.google.com/d/msgid/codenameone-discussions/769d0d0c-2f76-4dc0-b708-b8e963a74127%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Gareth Murfin (Android Freelancer - www.garethmurfin.co.uk) -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/CANOaY6nKOEnmQt4a8MSvfbETKCtUX68iqWYN%3DcUbKDeogEd%2BgQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
