How can we upload data to s3 on CodeName One?

79 views
Skip to first unread message

gao1...@gmail.com

unread,
Oct 30, 2017, 8:27:32 AM10/30/17
to CodenameOne Discussions

I want to upload like this:

// Initialize the Cognito Sync client
CognitoSyncManager syncClient = new CognitoSyncManager(
getApplicationContext(),
Regions.US_EAST_2, // Region
credentialsProvider);
// Create a record in a dataset and synchronize with the server
Dataset dataset = syncClient.openOrCreateDataset("myDataset");
dataset.put("myKey", "myValue");
dataset.synchronize(new DefaultSyncCallback() {
@Override
public void onSuccess(Dataset dataset, List newRecords) {
//Your handler code here
}
});

Above code snipped is the source for the native android development to upload the data to s3

Please let me know the same way used in Codename One

Shai Almog

unread,
Oct 31, 2017, 12:57:08 AM10/31/17
to CodenameOne Discussions
I'm not familiar with that API but you need to use the REST API that AWS provides and not the Java API which is designed for Java EE.
If you can reference a specific REST API I can explain to you how to translate that to Codename One code.

gao guangli

unread,
Nov 2, 2017, 3:29:45 AM11/2/17
to codenameone...@googlegroups.com
Dear Shai

Thanks for your support.

I tried to find the restful api to sync the data to s3, but I could only the api to upload the file, not sync the data to s3.

And Codename One doesn't provide the api to sync the data as well, so I'm not sure how I can implement this problem using Codename One.

Please help me to indicate the way to fix the issue.

I'm looking forward to your answer.

Best regards,
Xander

On Mon, Oct 30, 2017 at 9:57 PM, Shai Almog <shai....@gmail.com> wrote:
I'm not familiar with that API but you need to use the REST API that AWS provides and not the Java API which is designed for Java EE.
If you can reference a specific REST API I can explain to you how to translate that to Codename One code.

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.
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/d10be4a0-83ad-469f-b3cf-1afaac0b40ca%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Shai Almog

unread,
Nov 3, 2017, 1:30:00 AM11/3/17
to CodenameOne Discussions
Hi,
as far as I know and have used S3 I only used it as a file upload API and haven't used it as anything else.
If you have a specific REST API from Amazon that you need to do in Codename One I can help you with that but I'm just not familiar enough with the API to understand what you are trying to accomplish.

gao guangli

unread,
Nov 3, 2017, 10:24:08 AM11/3/17
to codenameone...@googlegroups.com
Hi Shai
I understand and I will use my own restful api
I have one more question: Why I can't import JSONObject on codename one?

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

gao guangli

unread,
Nov 3, 2017, 10:25:43 AM11/3/17
to codenameone...@googlegroups.com
Can you show the full example to use the Post restful api?

On Fri, Nov 3, 2017 at 7:24 AM, gao guangli <gao1...@gmail.com> wrote:
Hi Shai
I understand and I will use my own restful api
I have one more question: Why I can't import JSONObject on codename one?
On Thu, Nov 2, 2017 at 10:30 PM, Shai Almog <shai....@gmail.com> wrote:
Hi,
as far as I know and have used S3 I only used it as a file upload API and haven't used it as anything else.
If you have a specific REST API from Amazon that you need to do in Codename One I can help you with that but I'm just not familiar enough with the API to understand what you are trying to accomplish.

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsubscr...@googlegroups.com.

Shai Almog

unread,
Nov 4, 2017, 1:35:31 AM11/4/17
to CodenameOne Discussions
There is a cn1lib that includes JSONObject we have our own JSON parser. 
There is some discussion of using a webservice in this video https://www.codenameone.com/how-do-i-use-http-sockets-webservices-websockets.html

As well as here:

gao guangli

unread,
Nov 4, 2017, 11:32:11 AM11/4/17
to codenameone...@googlegroups.com
Hi Shai
Yes, I saw the above links but terse is not worked for http post(because of the cast Respose<Map> to Map<String, Object>)
And I got the source you posted as well:

ConnectionRequest post = new ConnectionRequest(){
    @Override
    protected void buildRequestBody(OutputStream os) throws IOException {
        os.write(json.toString().getBytes("UTF-8"));
    }

    @Override
    protected void readResponse(InputStream input) throws IOException {
       // parse response data
    }
};
post.setUrl("http://localhost:8093/halimatbank/cbs/staff");
post.setPost(true);
post.setContentType("application/json");
I tried above code but the buildRequestBody() is not invoked and never worked.
Seems that I missed one configuration.

Would you like to hint me what I'm missing?

Regards

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.

Shai Almog

unread,
Nov 5, 2017, 12:59:48 AM11/5/17
to CodenameOne Discussions
Did you add it to the network queue using addToQueue?

gao guangli

unread,
Nov 6, 2017, 12:01:16 PM11/6/17
to codenameone...@googlegroups.com
Hi Shai
I missed to use the addToQuee.. Now it is working
And I have one more question: Which app can I use on the phone to scan the QR code to run the build?
Thanks

On Sat, Nov 4, 2017 at 9:59 PM, Shai Almog <shai....@gmail.com> wrote:
Did you add it to the network queue using addToQueue?

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Nov 7, 2017, 12:22:40 AM11/7/17
to CodenameOne Discussions
I just use anything that comes up with "QR code Scanner" they pretty much all work.

gao guangli

unread,
Nov 10, 2017, 1:35:48 PM11/10/17
to codenameone...@googlegroups.com
Hi Shai

Do you have the navigation sample or video using new GUI build?
I'm not sure how I can make the register, login and main page.

Regards

On Mon, Nov 6, 2017 at 9:22 PM, Shai Almog <shai....@gmail.com> wrote:
I just use anything that comes up with "QR code Scanner" they pretty much all work.

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

gao guangli

unread,
Nov 10, 2017, 1:44:47 PM11/10/17
to codenameone...@googlegroups.com
I have the MyApplication.java(main) in the project and I created the registerForm 
I want to set the navigation between MyApplication and registerFrom. 
Please let me know the solution

On Fri, Nov 10, 2017 at 10:35 AM, gao guangli <gao1...@gmail.com> wrote:
Hi Shai

Do you have the navigation sample or video using new GUI build?
I'm not sure how I can make the register, login and main page.

Regards
On Mon, Nov 6, 2017 at 9:22 PM, Shai Almog <shai....@gmail.com> wrote:
I just use anything that comes up with "QR code Scanner" they pretty much all work.

--
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/9O8cwEkgfrQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsubscr...@googlegroups.com.

Shai Almog

unread,
Nov 11, 2017, 12:33:09 AM11/11/17
to CodenameOne Discussions
Just bind an action listener to a button that will trigger that event then in the code use otherForm.show(); or new OtherForm().show();
We'll try to add a module to the academy with the new GUI builder
Reply all
Reply to author
Forward
0 new messages