File Chooser URL only working in current session?

0 favourites
  • 6 posts
From the Asset Store
Source File, music and art pack for Android Negotiator
  • Problem Description

    I saved the blob URL for an image with local storage and when I load it in a new session no image is shown (shows error when you open it in the browser)

    Attach a Capx ... obURL.capx

    Description of Capx

    allows you to select an image and save/load the file url to local storage. it works fine in the current session but if you close and reopen the browser the image is not showing and the url is not working anymore.

    Steps to Reproduce Bug

    • load an image
    • hit save button
    • hit load to load the image
    • close browser/reopen and click Load

    Observed Result

    if you close and reopen the browser the image is not showing and the url is not working anymore.

    Expected Result

    the local file should be displayed

    Affected Browsers

    • Chrome: YES
    • EDGE: YES
    • Safari: YES
    • NW.js export: YES

    Operating System and Service Pack

    Win10 64bit and on iOS in Safari

    Construct 2 Version ID

    latest beta, 242

  • When you pick a file, the browser loads it, and assigns a temporary URL to it. When the browser decides that the data isn't needed anymore (or when you close the browser) it unloads it, and the URL becomes invalid. The URL isn't a shortened version of the filepath, nor a shortened version of the image itself. It's a temporary name assigned to a temporary blob of data. There's no Construct 2 bug here.

    What you need to do, is save the actual image, instead of a temporary name for the image.

  • Thanks. But the manual did not mention its only temporary.

    Maybe this could be added? Ashley

    Do you know a way to save and restore the images? Johncw87

  • Well, you can get the image data from the blob URL by using the AJAX plugin, but restoring that back into a sprite isn't something I have a solution for off the top of my head.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I found a plugin from Pode which converts images to a base64 string and injects it back into sprites. I will try if it works.

    Maybe the system>save/load actions work too, to save all images in a "snapshot"?

  • This is by design. The file chooser URL is more like a shortcut to the data, it doesn't actually represent the data itself, and reloading the browser clears the data away. So you can't save a file chooser URL, you have to read the data or not use it at all.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)