What mime type should I use for CSV ZIP files? - mime-types

I am trying to send an email using Simple Java Mail API. The email will contain a CSV ZIP file attachment. Should I use text/csv or application/zip for the mime type of the attachment?

A zip file is a zip file, no matter what it contains.
It should be application/zip.
It is not a CSV file, if you tried to parse it as CSV it would fail. It is not text/csv.

In linux, you can find way much of the in the following file: /etc/mime.types.
See below to find out what mime is suitable for zip files.
grep zip /etc/mime.types
application/bacnet-xdd+zip xdd
application/epub+zip epub
application/gzip gz tgz
application/lpf+zip lpf
application/prs.hpub+zip hpub
application/tlsrpt+gzip
application/vnd.airzip.filesecure.azf azf
application/vnd.airzip.filesecure.azs azs
application/vnd.comicbook+zip cbz
application/vnd.d2l.coursepackage1p0+zip
application/vnd.dece.zip uvz uvvz
application/vnd.espass-espass+zip espass
application/vnd.etsi.asic-e+zip asice sce
application/vnd.etsi.asic-s+zip asics
application/vnd.exstream-empower+zip mpw
application/vnd.ficlab.flb+zip flb
application/vnd.gov.sk.e-form+zip
application/vnd.imagemeter.folder+zip imf
application/vnd.imagemeter.image+zip imi
application/vnd.iso11783-10+zip
application/vnd.laszip
application/vnd.logipipe.circuit+zip lcs lca
application/vnd.software602.filler.form-xml-zip zfo
application/vnd.stepmania.package smzip
application/zip zip
image/vnd.airzip.accelerator.azv azv
model/vnd.usdz+zip usdz
application/x-bzip2 bz2

Related

How to load a table with multiple zip files in Snowflake?

I'm trying to upload data to a Snowflake table using a zip file containg multiple CSV files but I keep getting the following message:
Unable to copy files into table. Found character '\u0098' instead of
field delimiter ',' File 'tes.zip', line 118, character 42 Row 110,
column "TEST"["CLIENT_USERNAME":1] If you would like to continue
loading when an error is encountered, use other values such as
'SKIP_FILE' or 'CONTINUE' for the ON_ERROR option. For more
information on loading options, please run 'info loading_data' in a
SQL client.
If I skip the errors some data load but it is like snowflake is not properly opening the zip file and I just get some random characters like if the zip file was only opened with notepad.
I tried changing the File Format Compression Method to all the available ones: Auto, Gzip, Deflate, Raw Deflate, Bz2m Brotli, Zstd and None. Getting different error messages.
I know my Zip file is compressed using the standard Deflate compression method but when I select this type I'm getting the following error:
Invalid data encountered during decompression for file: 'test.zip',compression type used: 'DEFLATE', cause: 'data error'
The "Auto" method sends the same error message as None
I also tried with zip files containing only one file and I get the same errors. The files that worked correctly were an uncompressed one (CSV) and one compressed using GZ but I need this to work using a zip file containing multiple CSVs
A zip file is not a DEFLATE file, even though zip uses deflate. All the compression methods supported are single file compression methods. Where-as zip is a file archive, thus why it has many files, which would be similar to are tar.gz which is also not supported.
Thus you will ether need to uncompress your files yourself, in your S3 bucket, or alter your data export tool to conform.
CREATE FILE FORMAT help

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.

Define a MIME type for .TXT files for Tika

I want to define the MIME type of *.txt files: text/txt, so that Tika can apply a more specific parser than the one used for text/plain files.
The glob *.txt is included in the definition of the type text/plain in tika-mimetypes.xml. Moreover, it seems to me that you cannot redefine a MIME type in custom-mimetypes.xml, only add new globs or magic patterns. Additionally, if I define the text/txt type in tika-mimetypes.xml as a subtype of text/plain with only the glob *.txt, Tika still detects a txt file as text/plain.
Is it absurd to define a subtype of text/plain only for txt files? If not, is it possible to define it only with custom-mimetypes.xml? If not, what is the easiest way to extend tika so that it can parse txt files differently than (let's say) STEP 3D CAD .stp files or .cfg files?
The use case in detail: I have a large source of data composed of (recursive) archives. Some plain text files are huge and I don't want Tika to parse them. However, I want to keep all the txt files.
Edit: specify that I don't want to keep .cfg files either (*.cfg is a glob of text/plain)

Ruby Zlib: What is the purpose of orig_name=?

My code is like this:
gz = Zlib::GzipWriter.open('test.zip')
gz.orig_name = "test.csv"
gz.write("testing writing to zipped file")
gz.close
What I am trying to do:
When using zip extractor application, test.zip will be unzipped to test.csv
I used orig_name method thinking that when I will try to extract the zip with other zip extractor like archive utility, the resulting file would be 'test.csv'. But the file is still 'test'.
If by "other zip extractor" you mean the gzip utility, you'd need to use the -N option of gzip to use the name stored in the gzip header. Otherwise it will just use the compressed file name with the .gz removed.

What's the content type of a .ini file?

I'd like to make a dynamically generated .ini file available for download, is there a standardized value for the Content-Type of .ini files?
I've found some places saying it's text/plain, but I'm a bit dubious.
Checking with the IANA list of MIME Media Types shows us that .ini is not listed in the list of media types (and in particular, in the list of Text Media Types.)
Additionally, the Wikipedia entry on .ini files explains that .ini files are really just "simple text files."
One way to verify these findings is to run the following command on a given .ini file (in *nix, at least):
$ file --mime-type php.ini.default
which gives us the following result:
php.ini.default: text/plain

Resources