cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the mime type of a file?

sam69
Champ in-the-making
Champ in-the-making
Hi,

I want to get the mime type of a file when I get a ResultSet from the WebService. I searched, but it's not in the columns of the row..

Here is my code :

QueryResult rootChildren = WebServiceFactory.getRepositoryService().queryChildren(refEspaceAlfresco);
    ResultSet rootChildrenResults = rootChildren.getResultSet();
    ResultSetRow[] rowsElementsDuLot = rootChildrenResults.getRows();
    ResultSetRow row = null;
    ResultSetRowNode rsNode = null;
    for (int i = 0; i < rowsElementsDuLot.length; i++)
    {
      row = rowsElementsDuLot[i];
      if (row.getNode().getType().equals(Constants.TYPE_CONTENT)) {
        [b]Here I want to get the mime type of the file… [/b]
      }
     

Thanks in advance for your help !

Regards,
Samuel
5 REPLIES 5

sam69
Champ in-the-making
Champ in-the-making
Nobody can answer me ? Or show me a ressource for webservice help.
Because I the Alfresco Webservice wiki page don't help me a lot. And I found the class structure not intuitive
The Web services sample are great, but not very complete.

Thanks in advance

sam69
Champ in-the-making
Champ in-the-making
I manage to gess the mime type with the file extension, but it's not a really good way, if the mime type is stocked somewere..

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

You want to look at the value of the content property returned in the query results.

On a normal content type node this is {http://www.alfresco.org/model/content/1.0}content.  Its value should look something like this …

 contentUrl=store://2006/4/26/16/a874f499-d539-11da-a07f-7f7271fd4b4e.bin|mimetype=text/plain|size=652|encoding=UTF-8

As you can see it is a string made up of the content location URL, the encoding and mimetype.

Currently there is no helper in the client to extract this information for you ( perhaps you counld add it 😉 ) but you should be able to extract the mime type fairly easily.

Hope this helps,
Roy

sam69
Champ in-the-making
Champ in-the-making
Thanks for your answer ! I already saw the mime-type here, but I though there was a better way…
Anymay, I keep the file-type extraction with the file extension, because it's enough for me, but maybe later 😉

darkhope
Champ in-the-making
Champ in-the-making
Is there any solution to open a file with the proper software ? The .bin extension launchs a specific program which can't read the file.
I've thought to create a copy of the file and rename the .bin with the mimetype informations, but I would like to know if there is a faster way to do it ?
Getting started

Tags


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.