Uploading images

Hello, when i drag an image to the VS directory, after its uploaded it looks like:

It is uploaded as any other file like js or html, (not in assets). If i upload file to assets can i acces it somehow with fs?

Hey @TGamingStudio I haven’t tried uploading images to VS Code, but that’s about what I would expect - I believe to make that work more consistently we would need to replicate the way the Editor handle binary files (including the appropriate policies and temporary permissions to allow the upload), and I don’t think that’s in the current VS Code Extension plan right now.

If you use the Editor to upload it and you want to use fs to manipulate the image, you’ll need to use wget or something similar in the project console to download the asset from its cdn.glitch.com address to your project’s file system.

@cori can I somehow load all assets and links in js code?

There’s not a great way to do that as far as I know, no. There is a hidden file called .glitch-assets in the project’s /app directory that should contain all the urls, though, so that might work.

How can i parse the data?
returns some objects. Can’t parse to JSON… Only can parse to String and its not an array :confused:

That’s true, the contents of that file are not valid JSON.

We have changes to asset storage in our plans that may completely get rid of that file, so I don’t think it’s likely that we’ll do the work to make that valid JSON, but if you were to take the content of that file and add [ before it, , between each line, and ] after it you should get something you can parse. You could also use jq in a script to create a proper JSON array using cat .glitch-assets | jq -s . and pipe it to a temporary file and parse that.