I am looking for some examples on storing some data into Google cloud storage using gae and Java. Looking at the APIs I didn't see enough information.
Any sample code will really help us a lot.
Ok so the solution was to set exclusive mode to true so that it remains locked by same request until object writing is completed
Related
I read one answer here (How to use Google Translate API in my Java application?) and started to use java-google-translate-text-to-speech api as it is free.
But when I use this api in a standalone java file, I am facing an issue : "Your client does not have permission to get URL /translate_a/t from this server. That’s all we know." HTTP Reponse Code 403-Forbidden error.
Do I need to use API key to use this api ?
Is there any sample code which uses API key ?
I am posting a question for the first time so apologies if the formatting is incorrect.
Thanks in advance !!
The official API is 20$ for 1 million characters (proportionally), so you could still consider using it as it's quite cheap.
The project you're referring to hasn't been updated in a long time, so it could just be broken due to changes by Google....
In the comments they also referenced this project, you could try using this, but I would still recommend the official API's.
I'm having the same problem as this and this but in the Java domain. This question also covers what I want but since no answers have been forthcoming I thought I'd ask it here, with a little more detail.
I'm most of the way through writing a Java application to back up files to Google Drive. As others have found, 'internal server error 500' failures are a pretty common problem with uploads, but for small files, implementing the recommended exponential back-off and retry works okay. For large files, however, (anything over a few MB) the failure rate is unacceptably high. In some cases I'm getting well over 50% failure rate, which makes any long backup job effectively impossible.
When inserting (uploading) a file using the Google Drive v2 API, the documentation clearly states that three upload types are available: simple, multipart and resumable. The upload type is specified by adding a parameter to the endpoint URL. Clearly, what I'm after is the resumable upload type.
The problem
There appears to be no method to set this uploadType parameter using the API. There's a method call to set every optional parameter (as detailed here), but not a sniff of a way to set uploadType to resumable. No code snippets, no documentation, no nothing.
Somewhat confusingly, there is also what appears to be an unrelated 'chunked' media upload mode, which is the default and which I've actually disabled in my application by calling request.getMediaHttpUploader().setDirectUploadEnabled(true), since it appears to make no difference whatsoever to the reliability of an upload, no matter what the chunksize is set to, and it hugely slows uploads down.
I'm on the verge of circumventing the API and building the requests manually, but I'd really like to know if anyone else has encountered/solved this first. It's such a glaring omission that I can't believe lots of folk haven't encountered it before.
Cheers all.
David.
Short answer:
The URI passed to MediaHttpUploader's resumable upload when you use the Google Drive java client API seems to be the same as the one proposed on Google Drive API V2. So actually by default the Google Drive Java client API is already using the resumable upload.
Long answer:
After tracing the code in Google Drive Java API client all the way from
com.google.api.services.drive.Drive
->com.google.api.services.drive.DriveRequest
->com.google.api.client.googleapis.services.AbstractGoogleJsonClientRequest
You will find that Drive's constructor passes the URI to DriveRequest, which also passes the variable uriTemplate to AbstractGoogleJsonClientRequest. And finally AbstractGoogleJsonClientRequest uses buildHttpRequestUrl() to generate the resumable URI proposed in Google Drive API reference. This URI is stored in the variable httpRequestUrl in AbstractGoogleJsonClientRequest. httpRequestUrl will then be passed to uploader's upload method. This method by default (directUploadEnabled defaults to false) will use the resumable upload instead of direct upload.
There is an example on this page https://developers.google.com/gdata/docs/resumable_upload?csw=1#InitialRequestJava
Now, here's where it gets confusing. That page allegedly refers to the old style Gdata api. However the current source code at https://code.google.com/p/google-api-java-client/source/browse/google-api-client/src/main/java/com/google/api/client/googleapis/media/MediaHttpUploader.java references that page as being the API that it implements.
I am trying to find the best way to transfer my huge data to google app engine datastore. We are java developers and it would be great if you can suggest the solutions around Google App Engine Java.
I have seen few solutions like google app engine pipeline, map reduce and tried them but nothing works. Is there any real solution that works?
Thanks,
Ramesh.V
What I did, split them into files of max 32MB? Upload them along with the backend source code and write a program on backend to fetch the data to datastore records... Mind you, each record has a maximum size of 1MB.
I do not know the best way, but have you looked at GAE/J's Remote API for Java?
Why don't you try Google BigQuery?
https://cloud.google.com/products/big-query
Here's a howto for the data transfer
For my website I wanted to store the IP address of every visitor.I had been doing this with derby+Tomcat,but I don't know how to do this with google appengine. How can I insert data to appengine's database ? I mean how do I connect to its database.
I have no idea how to do this.
NOTE : It will be great if somebody answers me with some code,that tells me how to connect to the database to start sending queries.
The link below is really a good introduction guide. You don't have to understand at all how Google App Engine datastore works to be able to store / retrieve data + there is a very active community to support you.
http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify
First of all, you need to select your interface for connecting to the GAE datastore. Your choices include:
the GAE low-level datastore API
JPA
JDO
Objectify
Twig
(apologies to any I have missed). Then you need to study the relevant documentation to find out how to use your selected interface.
Google app engine's datastore is a bit strange when comparing with other sql-databases. It needs quite a lot of learning.
But if you are not really interested in it, then you can try google's fusion tables. Its free and also it has SQL-like query mechanism.
It needs a slighter modification to your existing application. Signup for fusion tables then store and access your data through Fusion table API in App Engine.
Does google provide a Java server side api **(NOT java script).**I dont want the ajax api which works at clint side.
What i want is that the result returned for a keyword should return me search result in some specific data structure.Like List or set data structure.Then i want to manipulate the result according to my need in java code.
I had used such a java server site api for youtube.
They used to but is discontinued. Most likely because you can remove their ads ;-)
From Google's terms of service
You may not send automated queries of any sort to Google's system
without express permission in advance from Google.
So, no - use their AJAX API. The SAOP API is discoutinued, but I think you should be able to use it, unless it requires a key, in which case you are tied to the AJAX API
Technically, the statement quoted above doesn't mean you can't use some sort of server-side API - there are examples of that if you google around. It means you shouldn't do it, because sooner or later you will be blacklisted (banned), as violating the terms.
What you would be looking for now is the CustomSearch API:
They used to have a different API developers could use but it has been depreciated (Nov. 2009 I think) so this is a for cost service now. I am not aware how long it might have been a free service. The new API allows 100 free searches a day, but you have to be signed up for billing else anything above 100 searches will fail, here are the details:
http://code.google.com/apis/customsearch/v1/overview.html
And sorry yes, this would still be using Java Script but you could use this:
http://www.json.org/java/
There is at least a SOAP API that I'm aware of: Google SOAP Search API
I don't think Google wants 3rd parties to use their search engine for their own services/applications. You would get "we think you are a robot" error page as a result if Google thinks you are not a real person.
You can however try Google Custom Search