Discuss Scratch

paulallington
New to Scratch
8 posts

Using custom storage with scratch-gui

I'm trying to build (what felt like a) really simple project using scratch-gui, and building custom storage in to it, but I can't find any documentation anywhere, but I thought I'd seen it done. If I want to pass in a project id, and pull that project out of a database/file store somewhere (the mechanism doesn't matter), and then save it back to the same place, how would one do that?
apple502j
Scratcher
1000+ posts

Using custom storage with scratch-gui

You need to pass projectHost to the GUI, like this: https://github.com/LLK/scratch-www/blob/develop/src/views/preview/presentation.jsx#L343
You need API server for it. It must implement three things: GET /id for getting project.json, POST / for new project, and PUT /id for saving.

OSS Contributor & Translator of Scratch 3.0, Experienced Wikian @ enwiki, Admin @ jawiki
51 Pull Requests merged to LLK repository since April 4, 2018
Speaks English & Japanese

Scratch 3.0のOSS貢献者と翻訳者、英語版ウィキでExperienced Wikian、日本語版管理者
2018年4月4日から、51本のPRがいままでにLLKリポジトリにマージされました
日本語+英語
paulallington
New to Scratch
8 posts

Using custom storage with scratch-gui

apple502j wrote:

You need to pass projectHost to the GUI, like this: https://github.com/LLK/scratch-www/blob/develop/src/views/preview/presentation.jsx#L343
You need API server for it. It must implement three things: GET /id for getting project.json, POST / for new project, and PUT /id for saving.
Ah brilliant - that's exactly what I'm looking for thanks. Is there any docs/proper definition of what the api server needs to look like somewhere, error handling, json definition etc?
paulallington
New to Scratch
8 posts

Using custom storage with scratch-gui

I managed to put the projectHost in, and if I pass a projectId through then I can see it makes a call to “GET” the project. However I couldn't see how it would be saved. I tried setting the “canSave” property, however that just added another Save button to the menu, but it doesn't do anything. Is there something else I need to do in order to allow it to save projects as well?

Thanks for your help on this, it's much appreciated!
apple502j
Scratcher
1000+ posts

Using custom storage with scratch-gui

When saving, there are 2 things that needs to be saved - projects and assets (sounds and costumes).
This is set using assetHost (similar to projectHost) and needs 2 APIs - GET /internalapi/asset/md5ext/get/ and POST /md5ext
md5ext is MD5 and its extension, like 0cc175b9c0f1b6a831c399e269772661.svg

OSS Contributor & Translator of Scratch 3.0, Experienced Wikian @ enwiki, Admin @ jawiki
51 Pull Requests merged to LLK repository since April 4, 2018
Speaks English & Japanese

Scratch 3.0のOSS貢献者と翻訳者、英語版ウィキでExperienced Wikian、日本語版管理者
2018年4月4日から、51本のPRがいままでにLLKリポジトリにマージされました
日本語+英語
paulallington
New to Scratch
8 posts

Using custom storage with scratch-gui

How does projectHost work though? When I added it, Save didn't do anything - it didn't POST to the projectHost api that I set

Powered by DjangoBB

Standard | Mobile