SAFE-FS Desktop App

The function only puts one file at a time yes.

It is possible to write a function to handle whatever is in the file input, multiple files or single, and detect the file type.

Have a look at the links I noted above, there’s some pertinent examples on html5rocks, also I think mozilla have some good documentation and examples over here

1 Like

@joshuef As the network is agnostic about data, what would be the consequence of just specifying ‘binary’ for everything?

Detecting file types is unreliable and arbitrary anyway, so ends up being a mix of operating system settings and user intervention at times.

What do we lose if the metadata is set incorrectly (or perhaps set to a default, such as ‘unknown’). Or am i way off here… again? :slight_smile:

2 Likes

Hmmmmm, I’m not sure tbh of the implications of only sending binary. Certainly could be done.

I think (from a quick scan), the main purpose of MIME types if for receiving data. So if you’re putting an image on the network, it’s useful for the browser to know what that data is and what to do with it by default.

So maybe:

What do we lose if the metadata is set incorrectly

It’s less that and more ‘what do we gain when it is set correctly’?

But aye, I’m not really versed in this level of networking… :smiley:

2 Likes

No no no I mean file type

Like a text file or image file etc

Currently my button is only allowing text (.txt) files to be uploaded, not images or anything else

I’m confused.

A file can only be of one type…

You can set file inputs to allow multiple files to be set. That’s all in your HTML markup on the input. <input type="file" multiple />.

What you do with that file list and how you call safe-js to upload files (which yes, the createOrUpdateFile only handles one file of one type) is up to you…

Here’s a JS Bin that I put together for you to play with: JS Bin - Collaborative JavaScript Debugging

dataType = 'text/plain' is an ES6 standard called default parameters that allows the developer to specify a default, if the function parameter is undefined.

You just need to specify the type to upload files other than text/plain. See the JS bin link above.

4 Likes