[hg] galaxy 2506: Allow the upload of PDF files to libraries via...
details: http://www.bx.psu.edu/hg/galaxy/rev/ae750790079a changeset: 2506:ae750790079a user: Dan Blankenberg <dan@bx.psu.edu> date: Mon Jul 27 11:33:12 2009 -0400 description: Allow the upload of PDF files to libraries via the admin interface. A more generic method of determining binary files' type and whether they are allowed to be uploaded via the various upload methods should be created. 1 file(s) affected in this change: lib/galaxy/web/controllers/library_dataset.py diffs (29 lines): diff -r 5a92b5877cf7 -r ae750790079a lib/galaxy/web/controllers/library_dataset.py --- a/lib/galaxy/web/controllers/library_dataset.py Mon Jul 27 10:46:25 2009 -0400 +++ b/lib/galaxy/web/controllers/library_dataset.py Mon Jul 27 11:33:12 2009 -0400 @@ -73,12 +73,19 @@ ext = name.split( "." )[1].strip().lower() except: ext = '' - if not( ext == 'ab1' or ext == 'scf' ): - raise BadFileException( "you attempted to upload an inappropriate file." ) - if ext == 'ab1' and file_format != 'ab1': - raise BadFileException( "you must manually set the 'File Format' to 'Ab1' when uploading ab1 files." ) - elif ext == 'scf' and file_format != 'scf': - raise BadFileException( "you must manually set the 'File Format' to 'Scf' when uploading scf files." ) + try: + is_pdf = open( temp_name ).read( len( '%PDF' ) ) == '%PDF' + except: + is_pdf = False #file failed to open or contents are smaller than pdf header + if is_pdf: + file_format = 'pdf' #allow the upload of PDFs to library via the admin interface. + else: + if not( ext == 'ab1' or ext == 'scf' ): + raise BadFileException( "you attempted to upload an inappropriate file." ) + if ext == 'ab1' and file_format != 'ab1': + raise BadFileException( "you must manually set the 'File Format' to 'Ab1' when uploading ab1 files." ) + elif ext == 'scf' and file_format != 'scf': + raise BadFileException( "you must manually set the 'File Format' to 'Scf' when uploading scf files." ) data_type = 'binary' if not data_type: # We must have a text file
participants (1)
-
Nate Coraor