Saving and restoring image from database

I have an imageWell and want to save the image to a database and later retrieve it to fill the imageWell with the image. What’s the easiest way to do it? Also, I know that saving a URL rather than the image itself would be more efficient. But if I drop an image onto the imageWell, how can I retrieve the URL of the original file?

Why would you have a URL for an ImageWell? Is this a web project with a WebImageView?

If you’re on Desktop with an ImageWell you should look at the Picture documentation for how to save and restore a Picture object from data.

This is not a Web project. In my project there is a class of window called a CardWindow, which contains amongst other things an imageWell as an input for graphics. The data on each CardWindow is saved on a database. For example, the name of a CardWindow is stored in the CardName field of the database. I want to be able to save the contents of the ImageWell so that when a particular CardWindow is re-opened I can insert the image into the ImageWell from the database.

What is the size of the image stored in the ImageWell ?

It’s big. I’m inclining now to storing just the URL, but don’t know how to get the URL from a dragged picture file.

It may be possible on Mac, but you’d need declares if it was. I’m not sure if Windows system level drag objects are as helpful.

If the image is truly gigantic the best Xojo-only method would be to save the image data to a file in Application Support, and store the filename in the database.

If the user drops an image, it can come in one of 2 forms. It can be a file on the disk or an image from another application, such as the browser. If it’s a file, you get a FolderItem and you can access its NativePath directly (and by URL, I assume you meant Path, as in location on disk). If it’s an image, you get a Picture object that you can save to disk and use the Path to that location. See the documentation for ImageWell for example code to handle the DropObject event.

Note that storing a path in the database is more efficient as far as database storage goes, but it’s also much more fragile. If the user moves or deletes the file, your image can no longer be found.