file read and write

23 posts / 0 new
Last post
sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:
file read and write

Hi,

In the Tutorials page of Mosync webpage . it only gives an example of Reading and Writing Data . I could not find examples related to file read and write.

Can read "dynamic" files (image file, or other type file) or write its into a file system. How does Mosync framework manage it (where to read and write, own storage system like J2ME)?? Appreciate any examples!! Thanks.

Br,

T.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

There is a virtual file system in MoSync. It can't access existing files on the devices, but you can read and write your own files through the storage system. You need to inlcude MAFS.lib into your project, and then you can use standard C filestream commands (fopen, fwrite, etc). There aren't any MoSync specific tutorials at the moment on these, but the documentation here http://www.cplusplus.com/reference/clibrary/cstdio/ will be very useful.

Let me know if you've got any specific questions about this.

Thanks

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

I have a specific question, simply , let me make a user case example:

if people want to save a png type file into the storage system, and late read it from the storage system for showing. Later the file might be deleted.

My question:

1) Is the file name the identity in the storage system in order to read or write this file?
2) From the coding point of view, Take a look at the below

MAHandle imageResource;

imageResource = maCreatePlaceholder();

/* file write and read should be here, I am wondering how to use the "MAHandle" to make this easier, Could you give me a hint? Thanks! */

Image* i = new Image(0, 0, 240, 320, NULL, false, false, imageResource);

Thanks!!

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Ok, I've done this a lot. What you don't want to use is the virtual file system. What you want are MoSync stores.

What you would do is to save the PNG data to a store. When you open the store, you read the data into a placeholder, and then use maCreateImageFromData(). This will rebuild the image resource.

Have a look at the tutorial 'Reading and Writing Data'.

I've also written an ImageCache class. You request URLs of images from it. If it hasn't got it, it downloads it and stores in as a store. If it has already got it, it just loads it from the store and returns it to you. Its on another machine at the moment, but if I get a chance later, I'll post the code.

Sorry this is so brief

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

[attachment=0]ImageCacheListener.h[/attachment]
[attachment=1]ImageCache.h[/attachment]
[attachment=2]ImageCache.cpp[/attachment]

Have a look at this code. It downloads and saves PNG images to the device, using an MD5 hash of their original URL as a filename. You can see how to save and load images using it.

Hope this helps.

AttachmentSize
ImageCache.cpp 3.37 KB
ImageCache.h 1.02 KB
ImageCacheListener.h 680 bytes
sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

Rival, Thanks for your helping! It helps a lot...

I am trying to test the function that you have provided...... The follow questions I would like to ask:

1) Related to compiling problem. in your provided files, some headers are included as
#include "../std.h"
#include "Base64.h"
#include "MD5.h"

Are they included in the Mosync SDK package or what more I should do in order to avoid "Unresolved inclusion: " problem?

2) You commented out some codes as below, why??
/encUrl.clear();
//char* address = (char*)_nextRequest->getUrl();
//base64_encode(address, strlen(address), encUrl);
//char buffer[256];
//sprintf(buffer, "http://datilo.net/ImageCache/Default.aspx?encpath=%s", encUrl.c_str());
//sprintf(buffer, "%s", _nextRequest->getUrl());
//LOG("Requesting image from '%s'", _nextRequest->getUrl());

3) After briefly reading the code, the logic and I have got
a. as the data structure defined,

Vector _requests;
Downloader* dl;
Map _handles;
String encUrl;
String md5url;

Vector pointer _requests is used for keeping the downloaded url info. By Using an MD5 hash of their original URL as a file identity ( md5url = md5(_nextRequest->getUrl()).c_str(); ), we can use MD5 Hashed value for mapping it to MAHandle.
In your implementation, each download has own storage for saving. If people want to delete one file,just delete its own storage. Am I right? One more question comes up with my mind, what is the performance??

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

what I mentioned above "we can use MD5 Hashed value for mapping it to MAHandle", Map _handles is used to kept the mapping between md5url and own cache MAHandle ( refer to
maReadStore(store, cacheimage);
maCloseStore(store, 0);
_handles.insert(md5url, cacheimage); ).

after also reading the tutorial 'Reading and Writing Data'. What is an "efficient" way to update the data value in the Mosync storage. for instance, I save a value of variable into data storage, then I want to sync ( or update) the value of this variable in the data storage.

Please let me know if my question is not asked clearly. Thanks!

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
"sikamedia" wrote:

1) Related to compiling problem. in your provided files, some headers are included as
#include "../std.h"
#include "Base64.h"
#include "MD5.h"

Are they included in the Mosync SDK package or what more I should do in order to avoid "Unresolved inclusion: " problem?

These files are for educational purposes only, showing how to store images and load them again from storage. It was part of a much larger application

"sikamedia" wrote:

2) You commented out some codes as below, why??
/encUrl.clear();
//char* address = (char*)_nextRequest->getUrl();
//base64_encode(address, strlen(address), encUrl);
//char buffer[256];
//sprintf(buffer, "http://datilo.net/ImageCache/Default.aspx?encpath=%s", encUrl.c_str());
//sprintf(buffer, "%s", _nextRequest->getUrl());
//LOG("Requesting image from '%s'", _nextRequest->getUrl());

That's just debug. My ImageCache calls out to my web server, which returns resized images (there's no point sending massive, desktop sized pictures to the phone). It's just so I can see the url it is requesting from

"sikamedia" wrote:

3) After briefly reading the code, the logic and I have got
a. as the data structure defined,

Vector _requests;
Downloader* dl;
Map _handles;
String encUrl;
String md5url;

Vector pointer _requests is used for keeping the downloaded url info. By Using an MD5 hash of their original URL as a file identity ( md5url = md5(_nextRequest->getUrl()).c_str(); ), we can use MD5 Hashed value for mapping it to MAHandle.
In your implementation, each download has own storage for saving. If people want to delete one file,just delete its own storage. Am I right? One more question comes up with my mind, what is the performance??

Yes, each image is stored in its own file. I've not done any performance analysis, but it will definitely be faster having images in their own file, and not concatenated together.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
"sikamedia" wrote:

what I mentioned above "we can use MD5 Hashed value for mapping it to MAHandle", Map _handles is used to kept the mapping between md5url and own cache MAHandle ( refer to
maReadStore(store, cacheimage);
maCloseStore(store, 0);
_handles.insert(md5url, cacheimage); ).

after also reading the tutorial 'Reading and Writing Data'. What is an "efficient" way to update the data value in the Mosync storage. for instance, I save a value of variable into data storage, then I want to sync ( or update) the value of this variable in the data storage.

Please let me know if my question is not asked clearly. Thanks!

Yes, the Mapping is between md5 fingerprints and any MAHandle already loaded.

You can't poke values into stores. You have to read the entire store into a data object, change the value, and then write the entire store back.

Hope this helps.

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

For running and testing your provided the code, I tried to made an effort to port MD5 and want to pass the compilation in the Mosync SDK. just want to convince the solution. : )

After doing the porting MD5, I got the following compilation problem:

ImageCache.cpp:60: Error: Unresolved symbol '__ZN17ImageCacheRequest6getUrlEv',
ImageCache.cpp:102: Error: Unresolved symbol '__ZN17ImageCacheRequest6getUrlEv',
ImageCache.cpp:145: Error: Unresolved symbol '__ZN17ImageCacheRequest12getRequesterEv',
ImageCache.cpp:148: Error: Unresolved symbol '__ZN17ImageCacheRequestD1Ev',
ImageCache.cpp:30: Error: Unresolved symbol '__ZN17ImageCacheRequest12getRequesterEv',

All complain are the missing link, I guess it is related to ImageCacheRequest* _nextRequest (class ImageCacheRequest). I am wondering what additional libs should be added for this problem. Could you give a hint about it?? Thanks. By the way, if you want me to provide the ported MD5 files. Please let know.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

I'll send you my md5 code (and b64 code) if you really want it. I'll post ImageCacheRequest.cpp tomorrow if you want it, but I can't promise it will fix all of your problems as it probably has links into other things as well.

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

Please attach your md5 and b64 code, also related ImageCacheRequest.cpp and necessary files you think could help. I will try to fix it. Thanks!

chen
chen's picture
Offline
Joined: 10 Jul 2010
Posts:

Hi,

I'v got a problem on writing downloaded image to store. I got "Invalid resource type" error without any more information. The following is the complete code.
Could you please have a look at it? Thanks a lot!
Writting store code snip is in function: void finishedDownloading(Downloader *dl, MAHandle data)
#include
#include
#include
#include
#include
#include
using namespace MAUtil;
using namespace MAUI;
class MyScreen: public Screen, DownloadListener {
public:
MyScreen() {
lprintfln("Starting application");
idl = new ImageDownloader();
idl->addDownloadListener(this);
imageResource = maCreatePlaceholder();
lprintfln("Starting download");
String url =
"http://shop.abc.net.au/multimediaitems/images/product_images/4/482912.png";
idl->beginDownloading(url.c_str(), imageResource);
}
~MyScreen() {
delete idl;
maDestroyObject(imageResource);
}
//DownloadListener methods
void downloadCancelled(Downloader *dl) {
lprintfln("Cancelled");
}
void error(Downloader *dl, int code) {
lprintfln("Error: %d", code);
}
void finishedDownloading(Downloader *dl, MAHandle data) {
lprintfln("Completed download");
//Create a new image on screen with this picture
Image* i = new Image(0, 0, 240, 320, NULL, false, false, imageResource);
MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);
this->setMain(i);
this->show();
}
void notifyProgress(Downloader *dl, int downloadedBytes, int totalBytes) {
lprintfln("Downloaded %d of %d bytes", downloadedBytes, totalBytes);
}
private:
ImageDownloader* idl;
MAHandle imageResource;
};
class MAUIMoblet: public Moblet {
public:
MAUIMoblet() {
// initialize
screen = new MyScreen();
}
void keyPressEvent(int keyCode) {
// todo: handle key presses
}
void keyReleaseEvent(int keyCode) {
// todo: handle key releases
}
MyScreen* screen;
~MAUIMoblet() {
delete screen;
}
};
extern "C" int MAMain() {
Moblet::run(new MAUIMoblet());
return 0;
};

"rival" wrote:

Ok, I've done this a lot. What you don't want to use is the virtual file system. What you want are MoSync stores.

What you would do is to save the PNG data to a store. When you open the store, you read the data into a placeholder, and then use maCreateImageFromData(). This will rebuild the image resource.

Have a look at the tutorial 'Reading and Writing Data'.

I've also written an ImageCache class. You request URLs of images from it. If it hasn't got it, it downloads it and stores in as a store. If it has already got it, it just loads it from the store and returns it to you. Its on another machine at the moment, but if I get a chance later, I'll post the code.

Sorry this is so brief

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

as the tutorial mentioned:

If you tried this with a Downloader object instead of an ImageDownloader, you’ll get an ‘Invalid Resource Type’ error message when you tried to create the image. Instead, you’d need to call: maCreateImageFromData(h, source, position, imageLength);
to covert the resource type for you.

P.S. Chen, Your problem is with saving image data (file) into the store. I tired your code in the running time。

Error message is : MoSync Panic 40001. "Invalid resource type" The panic occurred in the syscall maWriteStore.

The error happens in the syscall, I am wondering whether the Mosync emulator supports maWriteStore() well in the windows env... compile your code and test it your phone and see what happen.

chen
chen's picture
Offline
Joined: 10 Jul 2010
Posts:

I tried Downloader, not working. And maCreateImageFromData is another topic about creating image.
Not working in phone either, but could you try it on your phone, maybe I do it incorrectly. But I believe, the emulator should support this.
Thanks.

"sikamedia" wrote:

as the tutorial mentioned:

If you tried this with a Downloader object instead of an ImageDownloader, you’ll get an ‘Invalid Resource Type’ error message when you tried to create the image. Instead, you’d need to call: maCreateImageFromData(h, source, position, imageLength);
to covert the resource type for you.

P.S. Chen, Your problem is with saving image data (file) into the store. I tired your code in the running time。

Error message is : MoSync Panic 40001. "Invalid resource type" The panic occurred in the syscall maWriteStore.

The error happens in the syscall, I am wondering whether the Mosync emulator supports maWriteStore() well in the windows env... compile your code and test it your phone and see what happen.

sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

since code

MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);

cause the problem, any hints or suggestions will be appropriated for solving it.

"chen" wrote:

Hi,

I'v got a problem on writing downloaded image to store. I got "Invalid resource type" error without any more information. The following is the complete code.
Could you please have a look at it? Thanks a lot!
Writting store code snip is in function: void finishedDownloading(Downloader *dl, MAHandle data)
#include
#include
#include
#include
#include
#include
using namespace MAUtil;
using namespace MAUI;
class MyScreen: public Screen, DownloadListener {
public:
MyScreen() {
lprintfln("Starting application");
idl = new ImageDownloader();
idl->addDownloadListener(this);
imageResource = maCreatePlaceholder();
lprintfln("Starting download");
String url =
"http://shop.abc.net.au/multimediaitems/images/product_images/4/482912.png";
idl->beginDownloading(url.c_str(), imageResource);
}
~MyScreen() {
delete idl;
maDestroyObject(imageResource);
}
//DownloadListener methods
void downloadCancelled(Downloader *dl) {
lprintfln("Cancelled");
}
void error(Downloader *dl, int code) {
lprintfln("Error: %d", code);
}
void finishedDownloading(Downloader *dl, MAHandle data) {
lprintfln("Completed download");
//Create a new image on screen with this picture
Image* i = new Image(0, 0, 240, 320, NULL, false, false, imageResource);
MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);
this->setMain(i);
this->show();
}
void notifyProgress(Downloader *dl, int downloadedBytes, int totalBytes) {
lprintfln("Downloaded %d of %d bytes", downloadedBytes, totalBytes);
}
private:
ImageDownloader* idl;
MAHandle imageResource;
};
class MAUIMoblet: public Moblet {
public:
MAUIMoblet() {
// initialize
screen = new MyScreen();
}
void keyPressEvent(int keyCode) {
// todo: handle key presses
}
void keyReleaseEvent(int keyCode) {
// todo: handle key releases
}
MyScreen* screen;
~MAUIMoblet() {
delete screen;
}
};
extern "C" int MAMain() {
Moblet::run(new MAUIMoblet());
return 0;
};

"rival" wrote:

Ok, I've done this a lot. What you don't want to use is the virtual file system. What you want are MoSync stores.

What you would do is to save the PNG data to a store. When you open the store, you read the data into a placeholder, and then use maCreateImageFromData(). This will rebuild the image resource.

Have a look at the tutorial 'Reading and Writing Data'.

I've also written an ImageCache class. You request URLs of images from it. If it hasn't got it, it downloads it and stores in as a store. If it has already got it, it just loads it from the store and returns it to you. Its on another machine at the moment, but if I get a chance later, I'll post the code.

Sorry this is so brief

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK, It seems that you can't write an Image resource to storage in the way I thought. If you are downloading and storing images, then you need to do a normal download, and call maCreateImageFromRaw().

I've tested this code.

#include
#include
#include
#include
#include
#include

using namespace MAUtil;
using namespace MAUI;
class MyScreen: public Screen, DownloadListener {
public:
MyScreen() {
lprintfln("Starting application");
idl = new Downloader();
idl->addDownloadListener(this);
imageResource = maCreatePlaceholder();
lprintfln("Starting download");
String url =
"http://shop.abc.net.au/multimediaitems/images/product_images/4/482912.png";
idl->beginDownloading(url.c_str());
}
~MyScreen() {
delete idl;
maDestroyObject(imageResource);
}
//DownloadListener methods
void downloadCancelled(Downloader *dl) {
lprintfln("Cancelled");
}
void error(Downloader *dl, int code) {
lprintfln("Error: %d", code);
}

void finishedDownloading(Downloader *dl, MAHandle data)
{
lprintfln("Completed download");
//Create a new image on screen with this picture
maCreateImageFromData(imageResource, data, 0, maGetDataSize(data));
Image* i = new Image(0, 0, 240, 320, NULL, false, false, imageResource);
MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);
this->setMain(i);
this->show();
}

void notifyProgress(Downloader *dl, int downloadedBytes, int totalBytes) {
lprintfln("Downloaded %d of %d bytes", downloadedBytes, totalBytes);
}
private:
Downloader* idl;
MAHandle imageResource;
};

class MAUIMoblet : public Moblet {
public:
MAUIMoblet() {
// initialize
screen = new MyScreen();
screen->show();
}

void keyPressEvent(int keyCode) {
// todo: handle key presses
}

void keyReleaseEvent(int keyCode) {
// todo: handle key releases
}
MyScreen* screen;

~MAUIMoblet() {
delete screen;
}

};

extern "C" int MAMain() {
Moblet::run(new MAUIMoblet());
return 0;
};

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Wholly unofficially Cool

http://www.screencast.com/t/Mzk2MDM0ZG

AttachmentSize
ImageCacheStarterApp.zip 23.43 KB
sikamedia
sikamedia's picture
Offline
Mobile Conjurer
Joined: 23 Jun 2010
Posts:

One small question in my mind...

according to the code:

MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, Innocent

I think the optimized code should be like below if I only want one time save:

MAHandle store = maOpenStore("hello", 0);
if(store != STERR_NONEXISTENT) {
maWriteStore(store, data);
maCloseStore(store, Innocent
}

if keep on calling maWriteStore(store, data) and maCloseStore(store, Innocent infinity, I guess the phone storage memory will be full...Am I right??

does maWriteStore() act append saving?? Thanks...

"rival" wrote:

OK, It seems that you can't write an Image resource to storage in the way I thought. If you are downloading and storing images, then you need to do a normal download, and call maCreateImageFromRaw().

I've tested this code.

#include
#include
#include
#include
#include
#include

using namespace MAUtil;
using namespace MAUI;
class MyScreen: public Screen, DownloadListener {
public:
MyScreen() {
lprintfln("Starting application");
idl = new Downloader();
idl->addDownloadListener(this);
imageResource = maCreatePlaceholder();
lprintfln("Starting download");
String url =
"http://shop.abc.net.au/multimediaitems/images/product_images/4/482912.png";
idl->beginDownloading(url.c_str());
}
~MyScreen() {
delete idl;
maDestroyObject(imageResource);
}
//DownloadListener methods
void downloadCancelled(Downloader *dl) {
lprintfln("Cancelled");
}
void error(Downloader *dl, int code) {
lprintfln("Error: %d", code);
}

void finishedDownloading(Downloader *dl, MAHandle data)
{
lprintfln("Completed download");
//Create a new image on screen with this picture
maCreateImageFromData(imageResource, data, 0, maGetDataSize(data));
Image* i = new Image(0, 0, 240, 320, NULL, false, false, imageResource);
MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);
this->setMain(i);
this->show();
}

void notifyProgress(Downloader *dl, int downloadedBytes, int totalBytes) {
lprintfln("Downloaded %d of %d bytes", downloadedBytes, totalBytes);
}
private:
Downloader* idl;
MAHandle imageResource;
};

class MAUIMoblet : public Moblet {
public:
MAUIMoblet() {
// initialize
screen = new MyScreen();
screen->show();
}

void keyPressEvent(int keyCode) {
// todo: handle key presses
}

void keyReleaseEvent(int keyCode) {
// todo: handle key releases
}
MyScreen* screen;

~MAUIMoblet() {
delete screen;
}

};

extern "C" int MAMain() {
Moblet::run(new MAUIMoblet());
return 0;
};

Fredrik Eldh
Fredrik's picture
Offline
Mobile Sorcerer
Joined: 16 Feb 2009
Posts:
Quote:
MAHandle store = maOpenStore("hello", 0);
if(store != STERR_NONEXISTENT) {
maWriteStore(store, data);
maCloseStore(store, Innocent
}

if keep on calling maWriteStore(store, data) and maCloseStore(store, Innocent infinity, I guess the phone storage memory will be full...Am I right??

does maWriteStore() act append saving?

That code is not safe. Store access may fail for any reason, so it should look more like this:

MAHandle store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
if(store < Innocent {
  // Show error message.
} else {
  maWriteStore(store, data);
  maCloseStore(store, Innocent
}

maWriteStore() completely overwrites the existing store, so if you keep writing to a store with the same name, the memory will not become full.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

MAHandle store = maOpenStore("hello", 0);
if(store != STERR_NONEXISTENT) {
maWriteStore(store, data);
maCloseStore(store, Innocent
}

I don't think that this will work - have you tried it?

If the store DOES already exist (i.e. it is not non-existent), then it will save, but we've already got got it. If it DOESN'T exist, it isn't created because there is no MAS_CREATE_IF_NECESSARY, and it isn't saved. You can't create new stores.

If you change store != STERR_NONEXISTENT to store == STERR_NONEXISTENT then if it DOES exist it won't be saved, and if it DOESN'T exist it can't be created. I think you need


MAHandle store = maOpenStore("hello", 0);
if(store == STERR_NONEXISTENT) 
{
store = maOpenStore("hello", MAS_CREATE_IF_NECESSARY);
maWriteStore(store, data);
maCloseStore(store, 0);
} 

When you save a store which is already on the device, then the old store is overwritten, so you won't just fill up the device. You can't append to a store currently, but I think that there is some work to add this functionality.

artiko
artiko's picture
Offline
Joined: 15 Mar 2011
Posts:

Hi Sam,
Actually I already try ImageCacheStarterApp. In ImageCache.cpp you save the image to store like this

void ImageCache::finishedDownloading(Downloader* downloader, MAHandle data){	
//Save to storage	
MAHandle store = maOpenStore(mMD5url.c_str(), MAS_CREATE_IF_NECESSARY);	
maWriteStore(store, data);	
maCloseStore(store, 0);	
returnImage(data);
}

And then I try another example from you. It is ImageDownloader. I add the same code to ImageDownloader

void ImageCache::finishedDownloading(Downloader* downloader, MAHandle data){	
//Save to storage        
String storeName = "img1";	
MAHandle store = maOpenStore(storeName.c_str(), MAS_CREATE_IF_NECESSARY);	
maWriteStore(store, data);	
maCloseStore(store, 0);
}

I think, nothing wrong with the code, but I got this error when I run it :

[14] Emulator connected.
[14] Starting download
[14] Downloaded 0 bytes
[14] Downloaded 4356 bytes
[14] Downloaded 5808 bytes
[14] Downloaded 8712 bytes
[14] Downloaded 11616 bytes
[14] Downloaded 13018 bytes
[14] Finished downloading
[14] MoSync Panic 40001. "Invalid resource type" The panic occurred in the syscall maWriteStore.

can you tell me why? because I think they are using the same code to save to the store.
Thanks a lot.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hmm it is a bit odd. It may be because that ImageCache downloads a standard binary resource. In ImageDownloader, it call maCreateImageFromData to create an image resource. It may be that you can't save the image resource. You will may have to save it before maCreateImageFromData() is called,