jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Sag <d...@visualitylife.com>
Subject Re: examples of writing binary data to JCR
Date Fri, 29 Apr 2005 14:25:30 GMT
hey David that's great and many thanks.  I was very close with my own  
code but your example filled in the blanks for me.  ta.  sorry for the  
delay but i went off on holiday for a few days.  ahh yorkshire is  
beautiful.

I updated it slightly to extract the actual mime type...  see methods  
below.

used the sun.net.www.MimeTable

     //  
------------------------------------------------------------------------ 
--
     /**
      * Return the filename without any path data, but with the suffix.
      *
      * @param   url  the url or path of the file
      *
      * @return  filename without any path data but including the suffix.
      */
     public static String getFilename(String url) {
         int i = url.lastIndexOf(File.separator);

         if (i == -1) {
             return url;
         } else {
             return url.substring(i + 1);
         }
     }

     //  
------------------------------------------------------------------------ 
--
     /**
      * gets the correct MIME content type for the given file.
      *
      * @param   url  the url of the file.
      *
      * @return  the mime type.
      */
     public static String getContentType(String url) {
         // get the mime type
         MimeTable mt = MimeTable.getDefaultTable();

         String mime = mt.getContentTypeFor(getFilename(url));

         return mime;
     }

cheers and thanks

dave


On 26/04/2005, at 12:48 AM, David Nuescheler wrote:

> hi dave,
>
> with respect to the question about importing binaries
> into the repository, i checked-in a simple fs-import example into
> the "examples"-contrib.
>
> http://svn.apache.org/repos/asf/incubator/jackrabbit/trunk/contrib/ 
> examples/src/java/org/apache/jackrabbit/examples/FSImport.java
>
> its main method takes one command-line argument specifying a
> path to a directory to be imported into the repositories root node.
>
> let me know if this is helpful at all...
> extensions, fixes and clean-up are very welcome ;)
>
> regards,
> david


Mime
View raw message