Posts

Showing posts from October, 2014

How to match date filed in Google Datastore

How to match date filed in Google Datastore Suppose you have an 'Employee' entity with updatedOn field (Date or timestamp type). You can use Date function to parse date string and filter your data. In GQL, you can use:   SELECT * FROM EmployeeObj where updatedOn > Date ('2014-09-25') Similarly in objectify, you can use filter           Objectify obfy = OfyService.ofy();           List<EmployeeObj> resultList = obfy.load().type(EmployeeObj.class) .filter("updatedOn > ", Date('2014-09-25'))                                                  .list();

Upload csv file at Google Cloud Storage using java

First do all required pre requiste as per google doc https://cloud.google.com/appengine/docs/java/googlestorage/ Now see the sample code for a csv file uploader using latest api public String uploadFileUsingGCSClient(String csvDate, String fileName, String dirName,String bucketName) throws IOException {  // init the bucket access     GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());     GcsFilename filename = new GcsFilename(bucketName+"/"+dirName, fileName);     GcsFileOptions fileOptions = new GcsFileOptions.Builder()    .mimeType("application/CSV")       .acl("public-read")    //.addUserMetadata("myfield1", "my field value")    .build();     GcsOutputChannel outputChannel = gcsService.createOrReplace(filename, fileOptions);          // write file using this st...