[owncloud-devel] File Preview for New File Type

Georg Ehrke developer at georgehrke.com
Tue Jul 29 19:40:32 GMT 2014


Hi,

On Jul29 2014, at 09:19 PM, Aaron Boxer <boxerab at gmail.com> wrote:

> Hello,
> Can someone please explain or point me to any docs on how
> to add file preview to new file type? I would like to preview .dcm
> files, which are DICOM medical images.
You need to write a class that implements certain methods:
- getMimeType() - this function should return 'application/dicom’ in your case.
- getThumbnail() - this function would return the actual preview.

You mentioned imagemagick in an earlier mail.
An example of a preview provider that uses imagick is the pdf provider:
https://github.com/owncloud/core/blob/master/lib/private/preview/pdf.php
(You can ignore the " . '[0]’” in the imagick constructor.)

Finally you need to register your preview providers.
You would put this line of code into your appinfo/app.php
```
\OC\Preview::registerProvider('OC\Preview\PDF’);
```

You shouldn’t use \OC\Preview directly, but sadly there is no public api function for this yet.
I’ll add one and I’ll also write a proper interface for preview providers.

Cheers,
Georg
> 
> Also, another question: is it possible to filter uploaded files to detect
> the actual file format? If a user uploads a file FOO.BAR which is actually
> a dicom file, is there a way of filtering and storing meta-data about the file?
ping @icewind :)
> 
> Thanks very much!
> Aaron
> _______________________________________________
> Devel mailing list
> Devel at owncloud.org
> http://mailman.owncloud.org/mailman/listinfo/devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20140729/b29f59fc/attachment-0001.html>


More information about the Devel mailing list