Reading the color codes in an SVG file

Does anyone have any insight on how I can read the code within an SVG file that has been uploaded to Bubble? I’m trying to extract the color codes that are saved in an SVG file to create a color palette from the uploaded file. I’ve gotten to the point that I can extract the colors when the file is uploaded as a TXT file, but I can’t figure out a way to change the file extension to TXT when an SVG is uploaded.

Any ideas on a way to do this?

I think you need write custom JS snippet.

What if you change the extension of your SVG file to .txt after the upload and “upload it again” (dynamically) with the new extension? Seems crazy, but it could work.

I did try that, but AWS doesn’t allow it to save as a TXT since it is expecting to see SVG at the end of the file that is being saved. Maybe I’m missing something in the process.

Any tips on this? I don’t know enough about JS to write it out. I’m good at copy/pasting code and reverse engineering it, but it’s definitely not my strong suit.

How are you isolating the HEX code from the .txt?? Using regex?

Yes. Precisely.

I don’t know if this can work, but I have a plugin that can take your file and rename it, including extension. This was used actually for a case that API return a file but without extension. So I have created a server side plugin that can get the file and upload it with the name you want to Bubble storage (and you can also set privacy rules if needed). Send me a PM and we can test your case with this plugin and see if this work. Actually it’s not published on plugin store and it’s a private one for now.

Awesome. Sending you a message now.

1 Like

@Jici and @nate8

Problem solved?

1 Like

Yes using the plugin that allow to take a file from Bubble storage and upload a new one with a different name

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.