Current capability for adding binary files to TW under node.js?

Hi I’ve read a little about the file upload plugin, but not clear what the current status is? I’m running 5.2.5 under node.js, and trying to add new filetypes that can be drag/dropped to add to wiki. Specifically I’m trying to add ms project files, but the files seem to get added as text data and I can’t open them afterward (unlike ms word and excel files that I can open and edit from the wiki, which is AWESOME).

Welcome @Shane_Ashby in this case the browser needs to have a viewer or handler for the file where most browsers have a PDF viewer, and Microsoft Office users have excel, word and powerpoint viewers OR embedding the application for these files.

  • You need to determine if there is an equivalent for your project files and or you are downloading the right file format to allow such a viewer.
  • If this does not get you anywhere we can explore other ways of importing MS Project information, embedding views or the in browser apps.
    • If you are going to take this approach are you just using tiddlywiki as a portal to these files or do you want to make use of the project information in tiddlers etc…?

Hi thanks for the response. Regarding use of project information in tiddlers - I’m assuming that would be much more complex. I would just like them to open in the application when I click on the ‘download binary data’ button, just like Word, Excel and PowerPoint. My guess is that “registerFileType” is how I’d add the filetype so it’s recognized as binary data. I tried adding that to boot.js, but when I reloaded the browser the change was gone, so I assume that file is autogenerated in the node.js setup?

Shane its being a while since I did this so I am not so sure what of I knew is still valid. Do you have your files online and do you use office 365?

  • I believe there are multiple ways to make use of Office app files.

What is you main intention for using it with TiddlyWiki?

I just installed Microsoft 365 via the Chrome store in Chrome trying to replicate you current experience but no luck so far.

Just to clarify, are you running into these problems while using the FileUploads plugin? If so, are the files you add to the wiki being uploaded to the files/ directory served by the node.js server?

That is strange. PPTX files are recognised by TiddlyWiki in the same way as DOCX and XLSX files. Or is this an older PPT file?

Hi, it may work ONNLY if you are using newer MPPX XML format. Othervise it may help to find and install Chrome extension to recall file URI as local path to call right application (as you may by calling it from Explorer window).

You can try to manually tell type of file (tiddler) by manually entering mime type for tiddler:

  • application/vnd.ms-project
  • application/xml.msproject

I cannot test it here, because I have not installed MSproject yet now, hope it helps instead.

This is my usecase too. And I just drag to import msppt file, and seems it has correct mime type in nodejs setup:

title: xxxPPT.pptx
type: application/vnd.openxmlformats-officedocument.presentationml.presentation

That’s the funny thing - it gets attached as application/vnd.ms-project, but it seems that TW doesn’t know that MS Project files are binary. Instead of getting the ‘binary data’ box with a link to “download” it, the content shows up in the tiddler like it’s text. The actual file gets dropped into the tiddlers folder like any other office file, and the accompanying .meta tiddler gets created, but I can’t open the file.

MS Project file (so .mpp) is what’s not working. PowerPoint, Excel and Word are all working fine. I’m using Office (and Project) 2016 BTW.

I’m using Office 2016, not 365. Building a knowledge base for my work, and I drag and drop relevant files into the wiki to incorporate. I’m not using the FileUploads plugin (does that work with node.js?) When I drop the files they are copied into tiddlers folder and a skinny tiddler (.meta) is created. However the content appears in the tiddler like it’s text (it’s not, so a lot of unreadable characters), and no button to open the binary content…

It’s like it’s doing the attaching step, but then doesn’t realize it’s binary content so can’t get it back out.

I currently have project 2016, so can’t use mppx. I noticed though that neither mpp or mppx are registered filetypes in boot.js, so will mppx even work?

Also I’m running Firefox, and it’s locked down by IT. I might be able to get an addon approved but it would be difficult, hoping to avoid that…

Not running FileUploads plugin, however I am using the external-attachments plugin.

I use it similarly, with drag and drop. It does identify the mime-type correctly, just doesn’t know it’s binary and so there’s no way to open it.

Well, browser may not have enough permission to open a file. TidGi app allows this by providing electron API to it. TidGi has a button to open tiddler file in default app.

I guess that’s possible, but other office apps work. Also, why does it not even show that it’s binary content? In that case, I’d expect TW to show that it’s binary content, but then just not open it…?

@Shane_Ashby I don’t have the answer but have some related material from my research, Sorry, I don’t have time to study further, especially since I don’t have project manager installed / in use.

  • Have a look at ContentType
  • the is Operator has a binary option,
  • see Control Panel > Info > Advanced > Editor Type
    • Look for tiddlers with the prefix $:/config/EditorTypeMappings/ perhaps clone and make a new one? set to binary for your new content type?
  • Note the use of Base64 for binary tiddlers
  • Tiddlers that are not binary make use of the editor and the editor toolbar buttons available, vary according to the type field ie content type
  • Instructions for adding new types to tiddlywiki

This issue is complicated by at least these tree factors;

  • The application and its supporting tools such as browser plugins
  • How the browser treats content of that application
  • Tiddlywikis presentation to the browser so the above two work

One or more of the above may be an issue, even something else, so it is a multi-factor issue, these are often the most annoying :nerd_face:

[Edited] Another lead? Office URI Schemes | Microsoft Learn

First thank you so much for helping (and thanks to everyone that replied!)

I added the new type as directed, and it’s getting interesting.

It’s still not showing the usual binary preview, but if I click edit, I get:

However when I click to open the file I get nothing. When I go into the tiddlers folder and try to open from there, Microsoft Project doesn’t recognize the file format. The file is a different size from the original BTW (about 25% larger).

Finally, notice that the URL of the file in the status bar of the browser is different that others. After “base64” the other ms office files have a hexadecimal string, however the project file appears url encoded. Is this a clue what’s going on?

Hi @Shane_Ashby the instructions that @TW_Tones gave pertain to the configuration for determining which editor should be used for a given content type. However, inside TiddlyWiki’s JavaScript code there is a bunch of more fundamental configuration data for each of the known content types, and it is here that the information for Project files is lacking. For those interested, the code can be seen on GitHub. Without that information, TW doesn’t know that Project files are binary, and so doesn’t correctly base64-encode the content of the file.

The mechanism for the registration of these file types is not currently fully extensible, and so from time to time we add file types that are of general usage. I’d be happy to add support for modern MPPX Project files, given that we already support other MS Office formats, but I’m not so sure about adding support for the older MPP format given that we support .docx but not .doc.

Instead, a custom JS module can be used to register the file type. Create a new tiddler with the following fields:

title: $:/_RegisterProjectFiles
type: application/javascript
module-type: startup

Copy the following text to the “text” field of the tiddler:

exports.name = "register-msproject";
exports.after = ["startup"];
exports.synchronous = true;

exports.startup = function() {
	$tw.utils.registerFileType("application/vnd.ms-project","base64",".mpp");
	$tw.Wiki.parsers["application/vnd.ms-project"]
};

Then save and reload the wiki before trying to import an MPP file.

EDITED TO REFLECT UPDATE BELOW

Yeah I’ve been comparing the imported version of the file to the original, and definitely don’t match. I was wondering about an encoding issue. Thanks!