cancel
Showing results for 
Search instead for 
Did you mean: 

Some imported files have '.txt' automatically appended to their name

Antonio_Abreu
Champ in-the-making
Champ in-the-making

I've also tried this with a regular file import and it has the same behaviour. But, I first noticed it while using Nuxeo Drive (v1.2.1 on OSX 10.9).

When I added some files to a synchronised folder on my local disk, they soon reappear duplicated by a file with the same name and .txt appended to it. For instance, if I add a file named myfile.properties to the folder, it synchronises with the platform, where I see it as myfile.properties, but on the drive folder a new myfile.properties.txt emerges. If I delete the myfile.properties.txt from the disk, both files are removed by the synchronisation.

Looking at the file metadata in the platform, I notice that it has a Title of myfile.properties and a Content of myfile.properties.txt.

This is happening with more that one file extension: *.properties, *.log, *.cnf, *.diff, *.list, etc.

Is there a MIME setting that can be configured to stop the .txt extension from being appended to the file name?

Thanks

2 REPLIES 2

ataillefer_
Star Contributor
Star Contributor

Hello,

I cannot really reproduce your use case, what I can reproduce is importing a test.properties file to the server via the "Import a file" button and synchronize its parent folder which creates a test.properties.txt file in the local folder. Your case is probably related to this behaviour and I will explain the reason.

When importing a file to Nuxeo through Drag and Drop, or the "Import a file" button or Nuxeo Drive (let's say test.properties), Nuxeo will create a document with a type depending on the file's mime-type. If it is text/plain, which is usually the case for the file extensions you're mentioning (*.properties, *.log, ...) a Note document is created.

When looking at such a Note document, indeed its tile is the original filename: test.properties, but in the "Main File" field of the Content section in the Summary tab you will see test.properties.txt. This "filename" is in fact not stored anywhere, but only generated on the fly for display. This makes sense as a Note document, contrary to a File document, only has a note:note field to store the text content, and uses the dc:title for its title, but no "filename" field as it is not a real file. Though it is seen as a file using what we call the BlobHolder interface, which allows to adapt the document to such a BlobHolder object and call #getBlob() to get a file containing the text content, which is actually downloadable from the Web UI and will be named test.properties.txt. This file name is generated from the document's title suffixed by .txt. And Nuxeo Drive uses this mechanism when downloading the file generated from a Note document, that's why you get the *.txt files in the local folder...

This Blob adaptation behaviour is handled by the BlobHolderAdapterComponent which creates a DocumentStringBlobHolder for Note documents. You can contribute a BlobHolderFactory to this service to implement a different behaviour for Note documents, as in fact its default logic is quite poor: it avoids appending .txt to a file already named xxx.txt but doesn't take into accoutn other extensions:

   String ext = ".txt";
   ...
   if (!title.endsWith(ext)) {
       title = title.concat(ext);
    }

You can also contribute to the plugins extension point of the FileManagerService service to define another importer than NoteImporter for text documents, for example using the DefaultFileImporter creating File documents, which should solve your issue.

So no simple solution here and Java code might be needed.

Hope this helps.

Same problem occurs with FreeMind files except the .mm file replaced by .mm.txt file.

Getting started

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.