Mapping of mimetypes for filename - mime-types

Is there a way to map a filename and not a filetype on a specific mimetype?
Im using .config/mimeapps.list as default. I need this because Chromium does match the current mimetypes with the file extension and not with filenames and the file i want to autostart does not have a extension.
Im using Fedora26.

Related

How to get file path from a file object in reactJS

I'm trying to pass a file from a form to a hashing function, the only problem is the hashing function takes a file path as an argument, not a file object. So my idea is to choose a file from a normal file input field and then some how extracting the file path from the chosen file.
I tried searching for the file path through the documentation, but i failed to find anything

How do I list all files in a directory for a directory name stored in a tensor?

I have a placeholder which will be fed by a string value. The string value represents a path to some directory name. In that directory there are different ".jpg" files. How can I ask TensorFlow to list all of those files?
In other words, I want to add a node to my computation graph which will result in listing the directory, if I run it through my session. Is there a way to do that?
You can do this either using or not TensorFlow. I will only show you how you can list all files in a certain directory using TensorFlow, using tf.gfile.ListDirectory. You don't even need placeholders (in this case).
import tensorflow as tf
dir_path = "."
print(tf.gfile.ListDirectory(dir_path))

jMimeMagic returning mime type for docx, pptx, jar files as application/zip

I read the mimetype for .docx file is application/vnd.openxmlformats-officedocument.wordprocessingml.document. But when I upload a .docx file(one that I just created, not from a zip file) and check for its mimetype in my application using
String mimeType = Magic.getMagicMatch(file1, false).getMimeType();
I get Mimetype as application/zip.
I get the same result when I try to upload a .jar file.
I mean this way, how can I check if the user is uploading a msword or a jar file to my application?
All of the .*x Office variants (.docx, .pptx, and so on) are XML-based content which is wrapped in a ZIP "container" to keep them compact, and your library is detecting the ZIP header correctly but then either not checking for, or failing to find, the additional information that would allow it to distinguish those from a ZIP file containing whatever random data someone put into it.
Similarly, the JAR file format is an extension of the ZIP file format, so if the library does not know to check for the "special type of ZIP" case, it would simply report it as a ZIP file.

Huffman compressed files with my own extension

I am working on a project that uses Huffman algorithm to compress files, and I am doing my project using Java, what I want is to create my own file extension say (.huff) for the compressed file, and when I right click a file if it has the (.huff) extension, I want to add a new option which decompresses it, I searched the web but I did not find anything useful.
Any help would be appreciated.
To set the file extension just use one of the String methods like append(".yourExtension") (append it to the filename) and set as filename. Simple as that.
String filename = filename.append(extension);
To decompress the compressed file, I suggest you write a metod to which you provide a path to file as argument, check if the file extension is correct and then in another method you decompress this file.
There is nothing special about a file extension, it's just a part of the file name. To create a .huff file extension, just add .huff to the end of the file name.
To add the windows context menu, that's explained in the question linked in the comments How can I add a context menu to the Windows Explorer for a Java application?
I would recommend creating a batch script that will launch your program taking in the file to decompress as an argument.
Something similar to:
#echo off
java -cp <path-to-jar> <decompression main class> %1
Adding in any other setup or program arguments you need. Then a registry entry might look like.
HKEY_CLASSES_ROOT\.huff\shell\Decompress huffman encoded file\command
"<path to batch file>" "%1"

What is file name extension .done?

What is the file name extension ".done"?
How to handle the files with this extension? For example filename.log.gz.done is file name, can we just remove the done extension and use it?
What is the use of this file extension?
".done" is just a marker that signifies that the file is ready for consumption.
So yes, get rid of the done extension and use it.
More details can be found here: http://www.davsclaus.com/2010/12/camel-26-using-done-files-with-fileftp.html
The ".done" file extension may be appended onto any type of file, such as a .TXT or .LOG file, and may be found on an FTP server where multiple have access to the file. The DONE file helps prevents a user from accessing a file that is not meant to be accessed. The ".done" extension should be removed in order to open the actual file.
This takes you to the source from which I'm quoting my answer from. You will see a clear explanation of .done file extension and it's also a great reference for any other file extensions that you might need information about

Resources