Will google-file-service work on appengine-java-sdk-1.4.3.zip ?

19 views
Skip to first unread message

saran

unread,
Apr 21, 2011, 5:09:30 AM4/21/11
to GoogleFileService
Hi,
will i able to parse an Excel file which is already uploaded in GAE
datastore by using google-file-service.
I need to parse an Excel file using java and to get the values from
the same.

please help me . waiting for ur reply

cheers
saran

tytung

unread,
Apr 21, 2011, 12:14:42 PM4/21/11
to GoogleFileService
Please refer to FileDownloadServlet.java.
Get data from Google datastore and do what you need, e.g. parsing an
Excel file.

saran

unread,
Apr 25, 2011, 7:51:37 AM4/25/11
to GoogleFileService
hi tytung,

i gone through your code. I got the idea.

But my question is different.

I uploaded a excel file in your application by using my google
account.
https://gae-file-service.appspot.com/home.jsp

I am writing an web client. i.e servlet. in that i need to get the
file which i uploaded in ur apps. i.e https://gae-file-service.appspot.com/home.jsp.
So i need to connect my servlet (Web apps) to your application .ie
https://gae-file-service.appspot.com/home.jsp and to get download the
file which i uploaded.
How to do that ?

I tried after studying ur code but i got an exception that

java.lang.NullPointerException: No API environment is registered for
this thread.
@ DatastoreUtils.java line number 73.
g = pm.getObjectById(GoogleFile.class, fileId);

i understand that GoogleFile class is not made persistent. `coz i am
writing the servlet to download the file only by using fileid given
by ur apps when i uploaded my file .

but you wrote that code like user can download the file which is
uploaded. so the GoogleFile and GoogleUnits class made persistent
@ DatastoreUtils.java line number 171
pm.makePersistent(entity);

while uploading the file. so when downloading the file you can get
that file right ? but my case is different. I need to get the file
which already uploaded in GAE.

please correct me if i am wrong and also help me to get out from the
problem i facing dude.

cheers
saran

tytung

unread,
Apr 25, 2011, 12:56:14 PM4/25/11
to GoogleFileService
Hi saran,

I don't completely understand your question.
Do you mean your Java Servlet is running in your website, we say
https://YOURGFS.appspot.com/ ?
Then your Servlet would like to download a file from
https://gae-file-service.appspot.com/ and do the file processing.
If so, you just get a file from my website.
There's no differences whether the file download link is from
https://gae-file-service.appspot.com/ or from other websites.
You cannot use "GoogleFile g =
DatastoreUtils.getGoogleFileById(fileId);" in your Servlet in your
website to do more processing.

In other words, Servlet cannot cross the different domain, for
example, https://gae-file-service.appspot.com and https://YOURGFS.appspot.com.

tytung

On Apr 25, 7:51 pm, saran <saranpa...@gmail.com> wrote:
> hi tytung,
>
> i gone through your code. I got the idea.
>
> But my question is different.
>
> I uploaded a excel file in your application by using my google
> account.https://gae-file-service.appspot.com/home.jsp
>
> I am writing an web client. i.e servlet.  in that i need to get the
> file which i uploaded in ur apps. i.ehttps://gae-file-service.appspot.com/home.jsp.
> So i need to connect my servlet (Web apps) to your application .iehttps://gae-file-service.appspot.com/home.jspand to get download the

saran

unread,
Apr 26, 2011, 12:36:49 AM4/26/11
to GoogleFileService
hi tytung,

Thanks and good to see your reply. here i am explaining a complete
scenario. for example,

1) I logged in google account and open the https://gae-file-service.appspot.com/
page and uploaded a file.
for example say test.xls .
2) I am writing an webclient i.e servlet which runs in my local server
not in Google app engine server (www.my.appspot.com)and my local
server has internet connection
3) Through my webclient i.e servlet i want to download the file
(test.xls) which is uploaded in https://gae-file-service.appspot.com/
.
4) After downloading, i want to parse the excel file and to get the
data for my local processing.

This is what i actually want. This can possible or not ?

The datastore object is common to all appspot.com application or
private to each application ?
If datastore is private to each apps means you are correct, i.e
Servlet cannot cross the different domain, for
example, https://gae-file-service.appspot.com and https://YOURGFS.appspot.com.

please do reply .

cheers
saran

On Apr 25, 9:56 pm, tytung <tyt...@gmail.com> wrote:
> Hi saran,
>
> I don't completely understand your question.
> Do you mean your Java Servlet is running in your website, we sayhttps://YOURGFS.appspot.com/?
> Then your Servlet would like to download a file fromhttps://gae-file-service.appspot.com/and do the file processing.
> If so, you just get a file from my website.
> There's no differences whether the file download link is fromhttps://gae-file-service.appspot.com/or from other websites.
> You cannot use "GoogleFile g =
> DatastoreUtils.getGoogleFileById(fileId);" in your Servlet in your
> website to do more processing.
>
> In other words, Servlet cannot cross the different domain, for
> example,https://gae-file-service.appspot.comandhttps://YOURGFS.appspot.com.
>
> tytung
>
> On Apr 25, 7:51 pm, saran <saranpa...@gmail.com> wrote:
>
>
>
> > hi tytung,
>
> > i gone through your code. I got the idea.
>
> > But my question is different.
>
> > I uploaded a excel file in your application by using my google
> > account.https://gae-file-service.appspot.com/home.jsp
>
> > I am writing an web client. i.e servlet.  in that i need to get the
> > file which i uploaded in ur apps. i.ehttps://gae-file-service.appspot.com/home.jsp.
> > So i need to connect my servlet (Web apps) to your application .iehttps://gae-file-service.appspot.com/home.jspandto get download the

tytung

unread,
Apr 26, 2011, 1:33:04 AM4/26/11
to GoogleFileService
Hi saran,

It's possible.
Your scenario doesn't need https://gae-file-service.appspot.com/.
Any files download service can satisfy your need.
You just need to know a download link.
Then you can do steps 3 and 4.

Saved files (e.g., test.xls) in the datastore is private to each web
application.

tytung

On Apr 26, 12:36 pm, saran <saranpa...@gmail.com> wrote:
> hi tytung,
>
> Thanks and good to see your reply. here i am explaining a complete
> scenario. for example,
>
> 1) I logged in google account and open thehttps://gae-file-service.appspot.com/
> page and uploaded a file.
> for example say test.xls .
> 2) I am writing an webclient i.e servlet which runs in my local server
> not in Google app engine server (www.my.appspot.com)andmy local
> server has internet connection
> 3) Through my webclient i.e servlet i want to download the file
> (test.xls) which is uploaded inhttps://gae-file-service.appspot.com/
> .
> 4) After downloading, i want to parse the excel file and to get the
> data for my local processing.
>
> This is what i actually want. This can possible or not ?
>
> The datastore object is common to all appspot.com application or
> private to each application ?
> If datastore is private to each apps means you are correct,  i.e
> Servlet cannot cross the different domain, for
> example,https://gae-file-service.appspot.comandhttps://YOURGFS.appspot.com.
>
> please do reply .
>
> cheers
> saran
>
> On Apr 25, 9:56 pm, tytung <tyt...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi saran,
>
> > I don't completely understand your question.
> > Do you mean your Java Servlet is running in your website, we sayhttps://YOURGFS.appspot.com/?
> > Then your Servlet would like to download a file fromhttps://gae-file-service.appspot.com/anddo the file processing.
> > If so, you just get a file from my website.
> > There's no differences whether the file download link is fromhttps://gae-file-service.appspot.com/orfrom other websites.
> > You cannot use "GoogleFile g =
> > DatastoreUtils.getGoogleFileById(fileId);" in your Servlet in your
> > website to do more processing.
>
> > In other words, Servlet cannot cross the different domain, for
> > example,https://gae-file-service.appspot.comandhttps://YOURGFS.appspot.com.
>
> > tytung
>
> > On Apr 25, 7:51 pm, saran <saranpa...@gmail.com> wrote:
>
> > > hi tytung,
>
> > > i gone through your code. I got the idea.
>
> > > But my question is different.
>
> > > I uploaded a excel file in your application by using my google
> > > account.https://gae-file-service.appspot.com/home.jsp
>
> > > I am writing an web client. i.e servlet.  in that i need to get the
> > > file which i uploaded in ur apps. i.ehttps://gae-file-service.appspot.com/home.jsp.
> > > So i need to connect my servlet (Web apps) to your application .iehttps://gae-file-service.appspot.com/home.jspandtoget download the

saran

unread,
Apr 26, 2011, 1:49:48 AM4/26/11
to GoogleFileService
hi tytung,

Thanks dude. from your answer i understand that

i need to forward the request to file download service from my
servlet by passing the request and response object i.e in our case i.e
i need to forward the request to FileDownloadServlet.java right?

correct me if i am wrong

cheers
saran



On Apr 26, 10:33 am, tytung <tyt...@gmail.com> wrote:
> Hi saran,
>
> It's possible.
> Your scenario doesn't needhttps://gae-file-service.appspot.com/.
> > > Then your Servlet would like to download a file fromhttps://gae-file-service.appspot.com/anddothe file processing.
> > > If so, you just get a file from my website.
> > > There's no differences whether the file download link is fromhttps://gae-file-service.appspot.com/orfromother websites.
> > > You cannot use "GoogleFile g =
> > > DatastoreUtils.getGoogleFileById(fileId);" in your Servlet in your
> > > website to do more processing.
>
> > > In other words, Servlet cannot cross the different domain, for
> > > example,https://gae-file-service.appspot.comandhttps://YOURGFS.appspot.com.
>
> > > tytung
>
> > > On Apr 25, 7:51 pm, saran <saranpa...@gmail.com> wrote:
>
> > > > hi tytung,
>
> > > > i gone through your code. I got the idea.
>
> > > > But my question is different.
>
> > > > I uploaded a excel file in your application by using my google
> > > > account.https://gae-file-service.appspot.com/home.jsp
>
> > > > I am writing an web client. i.e servlet.  in that i need to get the
> > > > file which i uploaded in ur apps. i.ehttps://gae-file-service.appspot.com/home.jsp.
> > > > So i need to connect my servlet (Web apps) to your application .iehttps://gae-file-service.appspot.com/home.jspandtogetdownload the

tytung

unread,
Apr 26, 2011, 5:09:07 AM4/26/11
to GoogleFileService
No, in your case you don't need to study any source code of google-
file-service.
The below variable weblink can be any URL.

Source code in your Servlet:
-----------------------------------------------------------------------------------
String weblink = "http://example.com/download?id=123";
//String weblink = "http://example2.com/test.xls";
URL u = new URL(weblink);
connection = (HttpURLConnection) u.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int responseCode = connection.getResponseCode();
if (responseCode!= HttpURLConnection.HTTP_OK) {
// Log.message("loading failed", weblink+ "
"+connection.getResponseMessage()+" " + connection.getResponseCode());
return null;
}
int contentLength = connection.getContentLength();
InputStream is = connection.getInputStream();
return is;
-----------------------------------------------------------------------------------

Finally you will get a InputStream is, you can do any processing on
it.
> > > > Then your Servlet would like to download a file fromhttps://gae-file-service.appspot.com/anddothefile processing.

saran

unread,
May 9, 2011, 3:35:19 AM5/9/11
to GoogleFileService
hi tytung,
I wrote an small application for upload and download using Blobstore.
Thanks for your assistance in that. I do appreciate that for your kind
reply dude.
Please tell is this scenario will work or not

1) File uploading through blobstore and getting the blob key for the
uploaded file.
2) Getting the inputstream by using BlobStoreInputStream and the blob
key for the uploaded file.
3) Parse the excel file using Apachec POI and saving the data in an
POJO

Is it possible to store the POJO in datastore?

waiting for your reply
cheers
saran
Message has been deleted

tytung

unread,
May 9, 2011, 12:17:11 PM5/9/11
to GoogleFileService
I don't know.
I don't use POJO and don't write google-file-service anymore.
Please find out the answers by yourself.

On May 9, 3:35 pm, saran <saranpa...@gmail.com> wrote:
> hi tytung,

saran

unread,
May 15, 2011, 12:45:16 AM5/15/11
to GoogleFileService
hi tytung,
Thanks for your kind reply.
I understood.

cheers
saran
Reply all
Reply to author
Forward
0 new messages