cancel
Showing results for 
Search instead for 
Did you mean: 

bug: CSS (and js) file imported as a Note with incorrect mime-type text/plain instead of text/css

Milan_Simonovic
Champ on-the-rise
Champ on-the-rise

Observed behavior:

  1. open WebUI and navigate to a folder
  2. drag'n'drop a css file called styles.css
  3. press Import
  4. check the document type, it will be Note, with "note:mime_type" property set to "text/plain"

NuxeoUI on batch upload correctly sets the content type to text/css, there're 2 headers set on the POST request: "Content-Type: text/css" and "X-File-Type: text/css", but the follow up call to FileManager.Import seems to messes things up.

The same happens with a javascript file.

This can be reproduced with the javascript client calling the api:

const uploadFolder = '/';
const nuxeoBatch = nuxeo.batchUpload();
const fileContent = fs.readFileSync('styles.css');
const blob = new Nuxeo.Blob({
    content: fileContent,
    name: 'styles.css',
    mimeType: 'text/css',
    size: fileContent.length
});
nuxeoBatch.upload(blob);
nuxeoBatch.done().then((batch) => {
    return nuxeo.request(`/upload/${nuxeoBatch._batchId}/execute/FileManager.Import`)
                .post({ body: { context: { currentDocument: uploadFolder } } });
    }).then((uploaded) => {
//        uploaded[0].properties['file:content']['mime-type']  is not 'text/css' !
    });

What's weird is that if I first upload a pdf file, which correctly gets "application/pdf" mime-type, and then replace the contents with styles.css, then the mime type will be correctly set (guess coz this doesn't involve FileManager.Import).

1 REPLY 1

Milan_Simonovic
Champ on-the-rise
Champ on-the-rise

I've found 2 workarounds, one is to first create a Document with type File, and then upload binary. Another is with the latest v10.10, seems like it allows to suggest a type, so get an empty document with a @emptyWithDefault?type=File and then attach the blob.

Could this at least be tagged as a bug and and assigned to a JIRA issue?