File Preview for New File Type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

File Preview for New File Type

Aaron Boxer
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.

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?

Thanks very much!
Aaron

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File Preview for New File Type

Georg Ehrke-5
Hi,

On Jul29 2014, at 09:19 PM, Aaron Boxer <[hidden email]> 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:
(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
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel


_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File Preview for New File Type

Aaron Boxer
Thanks very much, Georg. It doesn't look to hard to do this.
First, I need to set up my dev environment, and then I will try to implement this.

By the way, adding DICOM support will be a huge win, I think.

Aaron


On Tue, Jul 29, 2014 at 3:40 PM, Georg Ehrke <[hidden email]> wrote:
Hi,

On Jul29 2014, at 09:19 PM, Aaron Boxer <[hidden email]> 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:
(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
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel



_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File Preview for New File Type

Robin Appelman-3
On Tuesday 29 July 2014 15:56:30 Aaron Boxer wrote:
> Thanks very much, Georg. It doesn't look to hard to do this.
> First, I need to set up my dev environment, and then I will try to
> implement this.
>
> By the way, adding DICOM support will be a huge win, I think.
>
> Aaron

Additionally, to make ownCloud recognize the mimetype use:

`\OC_Helper::getMimetypeDetector()->registerType(
        'dicom',
        'application/dicom'
)`

Note that this only has effect on files created after the mimetype is
registered

 - Robin Appelman
_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File Preview for New File Type

Aaron Boxer
Thanks, Robin.


On Tue, Jul 29, 2014 at 4:03 PM, Robin Appelman <[hidden email]> wrote:
On Tuesday 29 July 2014 15:56:30 Aaron Boxer wrote:
> Thanks very much, Georg. It doesn't look to hard to do this.
> First, I need to set up my dev environment, and then I will try to
> implement this.
>
> By the way, adding DICOM support will be a huge win, I think.
>
> Aaron

Additionally, to make ownCloud recognize the mimetype use:

`\OC_Helper::getMimetypeDetector()->registerType(
        'dicom',
        'application/dicom'
)`

Note that this only has effect on files created after the mimetype is
registered

 - Robin Appelman


_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File Preview for New File Type

Jos Poortvliet
On Wednesday 30 July 2014 10:02:41 Aaron Boxer wrote:
> Thanks, Robin.

Aaron, any chance you can put what you learn(ed) in a document so we can add
it to the documentation? The coolest would of course be a pull request on
github but without that - I'm willing to help...

> On Tue, Jul 29, 2014 at 4:03 PM, Robin Appelman <[hidden email]> wrote:
> > On Tuesday 29 July 2014 15:56:30 Aaron Boxer wrote:
> > > Thanks very much, Georg. It doesn't look to hard to do this.
> > > First, I need to set up my dev environment, and then I will try to
> > > implement this.
> > >
> > > By the way, adding DICOM support will be a huge win, I think.
> > >
> > > Aaron
> >
> > Additionally, to make ownCloud recognize the mimetype use:
> >
> > `\OC_Helper::getMimetypeDetector()->registerType(
> >
> >         'dicom',
> >         'application/dicom'
> >
> > )`
> >
> > Note that this only has effect on files created after the mimetype is
> > registered
> >
> >  - Robin Appelman

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel

signature.asc (205 bytes) Download Attachment