File Chooser URL only working in current session?

Bugs will be moved here once resolved.

Post » Fri Feb 03, 2017 7:20 pm

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
http://www.playbird.at/sites/Bl4ckSh33p ... 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
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Sun Feb 05, 2017 8:41 pm

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.
B
54
S
19
G
13
Posts: 97
Reputation: 10,146

Post » Mon Feb 06, 2017 2:47 pm

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
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Tue Feb 07, 2017 2:03 am

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.
B
54
S
19
G
13
Posts: 97
Reputation: 10,146

Post » Tue Feb 07, 2017 7:53 am

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"?
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Mon Feb 20, 2017 2:55 pm

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.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests