scratchfoundation / scratch-storage

Load and store project and asset files for Scratch 3.0
GNU Affero General Public License v3.0
59 stars 134 forks source link

How to Load Project Files into the Editor? #636

Open aquino-luane opened 2 months ago

aquino-luane commented 2 months ago

I have a .sb3 file that is returned from an API, and I want to load it into the editor when the app starts.

It seems that I need to set the project files into scratch-storage, but I am not sure if this is correct or how to do it.

Could someone please guide me on how to load the .sb3 file into the editor when the app starts?

Thank you!

mxmou commented 1 month ago

Loading a project from a file can be done using the loadProject() method from scratch-vm, which accepts the contents of the file as an ArrayBuffer. See the implementation of the "Load from your computer" option: https://github.com/scratchfoundation/scratch-gui/blob/cb056c5/src/lib/sb-file-uploader-hoc.jsx#L145-L171

aquino-luane commented 1 month ago

Loading a project from a file can be done using the loadProject() method from scratch-vm, which accepts the contents of the file as an ArrayBuffer. See the implementation of the "Load from your computer" option: https://github.com/scratchfoundation/scratch-gui/blob/cb056c5/src/lib/sb-file-uploader-hoc.jsx#L145-L171

I will check, thank you 🙏🏽