01-17-2019 07:20 AM
Observed behavior:
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).
02-04-2019 06:45 AM
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?
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.