Hi Bernd,

Well, I think that it is useful in a zip context too.

I could find in the EPUB spec[1] that they set the mime type for the EPUB zip archive using a mimetype file entry. It is the first entry in the archive, uncompressed, unencrypted and contains the string |application/epub+zip.|
we could have the same for Subsystems that would give us some benefits...

you can code something like this to have the mime type added to the archive:

byte[] mimetypeBytes = "application/vnd.osgi.subsystem"
                    .getBytes("UTF-8");
            ZipEntry mimetypeZipEntry = new ZipEntry("mimetype");
            mimetypeZipEntry.setMethod(ZipEntry.STORED);
            zOut.putNextEntry(mimetypeZipEntry);

And besides that, every zip file has a "magic number" [2] that you can use the identify whether an InputStream is a zip or not (50 4B 03 04 -> Zip Hex magic number). After certify that the stream is a zip archive you can read the zipentry and certify that it is a Subsystem archive.

and btw, there are no such mime type "application/java-archive" registered for JAR at IANA, check it here [3].

best regards,

Cristiano


[1] - http://en.wikipedia.org/wiki/EPUB#Open_Container_Format_2.0.1
[2] - http://www.garykessler.net/library/file_sigs.html
[3] - http://www.iana.org/assignments/media-types/media-types.xhtml

On 14-06-2014 18:07, Bernd Eckenfels wrote:
Hello,

Content Types are used if you have headers in a protocol. That can
typically be a HTTP Download or a Mime Email Attachment. They are
reserved typically along with the file extension, but both does not
affect the content of the (ZIP) archives.

The Content-Type for JAR is for example defined as
application/java-archive.



  Am Sat, 14 Jun 2014 16:41:15
-0300 schrieb Cristiano Gavião <[email protected]>:

Hi,

I'm working in a tool that generates subsystem archives and have some
doubts.

The spec states that:
A Subsystem is deployed as a Subsystem Archive (.esa) file.
Subsystem Archives are used to store
Subsystems and optionally their resources in a standard ZIP-based
file format. This format is defined
in [4] Zip File Format. Subsystems normally use the Subsystem
Archive extension of .esa but are not
required to. However there is a special MIME type reserved for OSGi
Subsystems that can be used to
distinguish Subsystems from normal ZIP files. This MIME type is:
application/vnd.osgi.subsystem
But I'm not sure if the mimetype entry *must* be in the archive file.

If it were not mandatory, implementations will be free to use the
entry file name (and extension) to distinguish valid contents... and
that could be problematic...
If you have a tool which does take the archives on the command line in
a context where it is not clear, it might be best to add a option which
qualifies the files' type.

Gruss
Bernd
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to