[ 7 posts ] 
Author Message
 Post subject: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Tue Sep 08, 2009 6:57 pm 

Joined: Thu Jul 16, 2009 3:01 pm
Posts: 126
Location: New York, NY
Can anyone confirm if Ajax requests to files located in the /media/internal area will return a response with the data in that file?

When I use Ajax.Request to get "file:///media/internal/wallpapers/04.jpg" I simply get an empty response.

But trying a file located in my app like "file:///var/usr/palm/applications/com.domain.test/images/one.png" -- it works. I get the binary content of the file in response.responseText

Is the XMLHttpRequest object restricted from returning responses for certain file paths? I can use <img src="file:///media/internal/wallpapers/04.jpg"> and thats fine - the image loads, but loading the same resource via Ajax.Request fails ...

_________________
--
Ryan Watkins
ryan.watkins@thumbplay.com


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Tue Sep 08, 2009 8:08 pm 

Joined: Thu Jul 16, 2009 2:36 pm
Posts: 352
new Ajax.Request("/media/internal/textfile.xml", ...
Worked for me. However, my app is named com.palm, I have no idea if this access is restricted. Try removing the file:// as well as try reading a true text file and see if either is possible in /media/internal maybe?

_________________
Jamie Hatfield/drnull
My webOS application: drPodder


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Tue Sep 08, 2009 8:56 pm 

Joined: Thu Jul 16, 2009 3:01 pm
Posts: 126
Location: New York, NY
Thanks for the suggestions - with a bit more investigation it seems specific to the JPEG file.

I was able to load an XML file off /media/internal, and then PNG file. I then loaded my own JPEG file rather than the system wallpapers and that worked as well. Tried copying the wallpaper from "/media/internal/wallpapers" to the "/media/internal" but it still failed to load. Even tried renaming it from .jpg -> .txt without changing the file contents, and that still failed.

So my only guess at this point is that something in the file contents is causing the request to fail? Need to do additional testing on the device to see if the behavior here is identical to the emulator.

_________________
--
Ryan Watkins
ryan.watkins@thumbplay.com


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Fri Sep 11, 2009 10:54 am 

Joined: Wed Sep 02, 2009 12:55 pm
Posts: 7
hi,

Have you checked the content of the file ? I tried the same thing but somehow the length of the responseText was incorrect. when i read an image file of 5216 bytes, the length of responseText is coming out 4904 bytes ?


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Fri Sep 11, 2009 11:16 am 

Joined: Wed Aug 05, 2009 5:30 am
Posts: 23
Location: Mumbai, India
amitajmani1 wrote:
hi,

Have you checked the content of the file ? I tried the same thing but somehow the length of the responseText was incorrect. when i read an image file of 5216 bytes, the length of responseText is coming out 4904 bytes ?


you cannot download binary
just convert image in base64 encoding

see viewtopic.php?f=11&t=1342


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Fri Sep 11, 2009 3:47 pm 
User avatar

Joined: Thu Jul 16, 2009 11:37 pm
Posts: 190
Location: Brooklyn, NY
The image attempting to be loaded is already on the device - an image reference returned by the file picker - its not something that was stored in base64.

I did look closer at this and some files that I saw were problematic were actually getting loaded. I was using Mojo.Log.error(response.responseText) and the value written to the log was getting truncated - so it appeared to me the file wasnt getting loaded, but there was actually content there when I query for response.responseText.length. But as pointed out, the length != bytes.

_________________
Ryan Watkins

ryan@ryanwatkins.net / @ryanwatkins
Paper Mache - http://www.ryanwatkins.net/software/papermache/


Top
 Profile  
 
 Post subject: Re: XMLHttpRequest - access restricted from /media/internal ?
PostPosted: Thu Sep 17, 2009 9:51 am 

Joined: Wed Sep 02, 2009 12:55 pm
Posts: 7
I tried reading images not available on Palm emulator. What I have done is, picked an image file from desktop and kept in my application path. There is no problem with image(verified it by reading binary content through Java) but still content length returned is not equal to actual image size. If image content is set as an innerHTML of any div, you will be able to see the contents on emulator. Is data returned in responseText in encoded form?


Top
 Profile  
 
Display posts from previous:  Sort by  
   [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron