@@ -76,43 +76,20 @@ const SBFileUploaderHOC = function (WrappedComponent) {
7676 if ( this . props . showOpenFilePicker ) {
7777 ( async ( ) => {
7878 try {
79- const extensions = [ '.sb' , '.sb2' , '.sb3' ] ;
8079 const [ handle ] = await this . props . showOpenFilePicker ( {
8180 multiple : false ,
8281 types : [
8382 {
8483 description : 'Scratch Project' ,
8584 accept : {
86- // Chrome on Android seems to track the MIME type that a file has when it is
87- // downloaded and then the file picker enforces that it must match one of
88- // the types given here. Unfortunately, Scratch projects are not a very popular
89- // file type so there is no actual standard and everyone uses a different
90- // string. We are thus forced to enumerate them all here so that the file picker
91- // actually works as Android does not allow the user to manually disable the
92- // type filters.
93-
94- // Most file hosting serivces won't recognize Scratch projects, so they'll
95- // serve it as an opaque byte stream.
96- 'application/octet-stream' : extensions ,
97-
98- // https://github.com/scratchfoundation/scratch-editor/blob/22f44c64a5287d6d511f4819f065270a6981f2c8/packages/scratch-vm/src/virtual-machine.js#L451C24-L451C53
99- 'application/x.scratch.sb3' : extensions ,
100-
101- // The dots are unusual, so sometimes hyphens are used instead.
102- 'application/x-scratch-sb3' : extensions ,
103-
104- // https://aur.archlinux.org/cgit/aur.git/tree/scratch3.xml?h=scratch3#n3
105- 'application/x-scratch3-project' : extensions ,
106-
107- // Used in various places but no clear origin
108- // https://github.com/search?q=%22application%2Fx-scratch2%22&type=code
109- 'application/x-scratch2' : extensions ,
110-
111- // https://aur.archlinux.org/cgit/aur.git/tree/scratch2.xml?h=scratch2#n3
112- 'application/x-scratch2-project' : extensions ,
113-
114- // https://github.com/scratchfoundation/Scratch_1.4/blob/d26f099e3d8358760d0129de4a57e792d97d146f/src/scratch.xml
115- 'application/x-scratch-project' : extensions
85+ // Chrome on Android tracks the MIME type of files that get downloaded and
86+ // then actually enforces that the type must match in showOpenFilePicker()
87+ // and does not allow the user to override the filter. As Scratch projects have
88+ // no well-defined and well-adopted MIME types, we can't assume anything about
89+ // what MIME type they are saved with, so we have to use the most broad MIME
90+ // type here. Otherwise some users just won't be able to load files for no
91+ // fault of their own.
92+ '*/*' : [ '.sb' , '.sb2' , '.sb3' ]
11693 }
11794 }
11895 ]
0 commit comments