espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 89 forks source link

file upload to storage #132

Closed RobertSmart closed 3 years ago

RobertSmart commented 3 years ago

Hi,

Is there a way to use this tool to manage stored files on the device? Kind of like the storage option in the IDE?

It would be really handy to be able to upload files directly to the device, and manage them.

Use case would be uploading html files for serving directly from the device. I can hardcode these directly into the js files, but it would be cleaner if we could bundle and then send to the device to be stored.

Thanks,

Rob Smart

gfwilliams commented 3 years ago

This should already be possible for file uploads:

  --storage fn:data.bin    : Load 'data.bin' from disk and write it to Storage as 'fn'
  --storage .boot0:-       : Store program code in the given Storage file (not .bootcde)

Actual management is tricky though - I feel like you're often better off just sending the relevant command - for instance espruino -e "require('Storage').erase('filename')"

RobertSmart commented 3 years ago

Hi,

Great thanks. I did look at the args I could pass, but must have missed that one.

So it is always best to erase the existing file before writing a new one?

Thanks,

Rob Smart

gfwilliams commented 3 years ago

So it is always best to erase the existing file before writing a new one?

It really doesn't matter - I wouldn't bother. It's just that you asked about 'management', so for more specific stuff like deleting I'd just send the JS command for it

RobertSmart commented 3 years ago

Hi,

Yes, the term management was probably a bit much. I was thinking of trying to make a gulp processor that would bundle, minify and upload the file to the module. I figured this would enable ease development and deployment. It should be easy enough to do that using the standard commands you mentioned.

Thanks very much.