I'm trying to learn the proper way of setting up Fileframework and I'm having trouble getting it to recognize PDF files. How do you get Fileframework to recognize PDF files?

I've also got a client that also wants it to recognize: .dwf, .dwg, .sldasm, .sldprt, .slddrw.

Is this possible?

Comments

justin.hopkins’s picture

Hey there. Fileframework should be using mime types to "recognize" files of different types.

Whether or not it can perform any actions on the file(s) would have to do with the ability/availability of tools to work on them - for instance it can only convert a pdf to plain text if you have the pdftotext utility installed on your system.

I've had issues with mime type recognition and webdav, but if you are uploading via web browser - the default settings are that Fileframework will get mime type info from you (your browser).

Look at admin/settings/file/mime - is pdf listed there?

If you are using webdav - and even if not, I've got an issue open #406182: Is it possible to rebuild file types (mime.types)? which is somewhat related...I'm trying to figure out how to get Fileframework to take another look at files which have already been added.

I am able to upload pdfs and dwf's without issue, it properly recognizes .dwf as model/vnd.dwf although fileframework doesn't do anything special with dwf's....you can download them :)

Hope that helps.

visualnotion’s picture

Thanks for the reply, Justin.

I've checked at the URL you referenced and PDF isn't anywhere in that list. Yes, we are uploading through the browser, at this point.

Any thoughts on how to add PDF to the list of mime types?

visualnotion’s picture

I have checked in Cpanel and the mime types listed there does list PDF. There just seems to be a disconnect somewhere between that and Fileframework.

justin.hopkins’s picture

You *might* try setting 'Server-side MIME type autodetection after upload' to 'Enabled' at admin/settings/file, but I haven't had much luck with that setting myself.

How this module handles MIME data isn't something I understand very well, so hopefully miglius will chime in on this soon.

miglius’s picture

Issue tags: +MIME

Here is how it works in the following steps:

1. File arrives with the MIME type sent by the browser which has uploaded the file.
2. If the MIME is missing or if it is unrecognized ('application/octet-stream'), then the MIME is guessed by the file extension using the mime.types file for the mapping.
3. If Server-side MIME type autodetection is enabled or set to conditional, the system does not trust the mime type the file has so far and MIME is being redetected on the server using php fileinfo extension or shell 'file' command.

The server side detection is used to avoid situations when a browser sends a wrong MIME type and a user has renamed the file by adding a false extension. This situation means that a wrong file conversion utilities would be used to build a derivative files. From my experience though, the fileinfo extension fails to correctly detect some mime types and therefore should be used with caution.

I'm planning to step away from the mime.types file and use more flexible and configurable mapping, see #282955: Use other file MIME detection instead of the mime.types file.

visualnotion’s picture

Thanks for the replies.

Miglius, when these changes are made in the settings, does this affect ALL current attached files or only new ones uploaded/attached after the settings are changed?

I'll see about trying the setting you mentioned in 3) on your list above, again.

miglius’s picture

The changes will affect only new files, but I see your point. If the file is already uploaded and them MIME is wrong, after changing the MIME table one has to reupload the file to set the proper MIME.

The redetection of MIME for currently uploaded files could be implemented, but I would need to think more what would be better - to do it per individual file, or should the script redetect MIMEs for all uploaded files in the system, which can be process intensive, since if on server autodetection is enabled, the file should be pulled from the bitcache, the MIME redetected and all new file conversions run again.

visualnotion’s picture

I was able to get PDFs working by adding this to the file_document.module in the file_document_mime_types() function:

'application/pdf' => array(
      'name' => t('Portable Document Format'),
      'icon' => 'acrobat.gif',
    ),

Is there a reason why this couldn't be included in the module for future releases?

I do recognize the complexity of the auto-update process and appreciate your willingness to work on it further. I'll keep an eye on future updates and these issues, though as I am interested in using fileframework on other projects as well.

miglius’s picture

Status: Active » Postponed (maintainer needs more info)

The way a MIME type is recognized has been changed drastically recently as of #282955: Use other file MIME detection instead of the mime.types file. Can you test the latest code to see if it solves the issue?

ZyanKLee’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.x-dev
Component: Documentation » Code
Category: support » feature
Status: Postponed (maintainer needs more info) » Needs review

I had a test on this: it works only with visualnotion's modification on the current dev version.

In addition I managed to get ff to convert pdf to txt (and zip) as well:

add this to the same file (file_document.module) to the end of the function file_document_mime_converters() around line 200:

    'application/pdf' => array(
      'text/plain' => array(
        'pipeline' => '{pdftotext} "[in_file]" "[out_file]"',
        'handlers' => array('file_text_text'),
      ),
      'application/zip' => array(
        'pipeline' => 'pwd="`{pwd}`"; {mkdir} "[in_file].tmp"; {mv} "[in_file]" "[in_file].tmp/[filename]"; cd "[in_file].tm$
      ),
    ),

One flaw: this does NOT ocr any image that may be in your pdfs, but just extracts text.

jvieille’s picture

Not sure what this issue is about.
pdf are well recognized and converted. See for example
http://web2.see.asso.fr/en/node/1922

johanneshahn’s picture

Status: Needs review » Closed (works as designed)

hi ZyanKLee,
this lines of code already in

/formats/slideshow/file_slideshow.module

near line 100:

'application/pdf' => array(
      'text/plain'.....

and in

/formats/archive/file_archive.module

near line 113:

 'application/zip' => array(
      'text/plain' => array(
        'pipe

i think the problem was in older fileframework 6.x-1.0-alpha3
u only need to install the file_slideshow and file_archiv module
then the application/pdf appears in mime list (/admin/settings/file/mime) and as
converter (/admin/settings/file/convert/converter)