|
@@ -504,25 +504,26 @@ class MediaUpload(MediaPath): |
|
|
result['size'] = self.get_file_size(fieldStorage.file) |
|
|
result['size'] = self.get_file_size(fieldStorage.file) |
|
|
|
|
|
|
|
|
if self.validate(result, fieldStorage.file): |
|
|
if self.validate(result, fieldStorage.file): |
|
|
|
|
|
local_filename = slugify( result['name'] ) |
|
|
# Keep mime-type in .type file |
|
|
# Keep mime-type in .type file |
|
|
with open( self.mediapath( result['name'] ) + '.type', 'w') as f: |
|
|
|
|
|
|
|
|
with open( self.mediapath( local_filename ) + '.type', 'w') as f: |
|
|
f.write(result['type']) |
|
|
f.write(result['type']) |
|
|
|
|
|
|
|
|
# Store uploaded file |
|
|
# Store uploaded file |
|
|
fieldStorage.file.seek(0) |
|
|
fieldStorage.file.seek(0) |
|
|
with open( self.mediapath(result['name'] ), 'wb') as f: |
|
|
|
|
|
|
|
|
with open( self.mediapath( local_filename ), 'wb') as f: |
|
|
shutil.copyfileobj( fieldStorage.file , f) |
|
|
shutil.copyfileobj( fieldStorage.file , f) |
|
|
|
|
|
|
|
|
if re.match(IMAGE_TYPES, result['type']): |
|
|
if re.match(IMAGE_TYPES, result['type']): |
|
|
result['thumbnailUrl'] = self.createthumbnail(result['name']) |
|
|
|
|
|
|
|
|
result['thumbnailUrl'] = self.createthumbnail(local_filename) |
|
|
elif result['type']=='application/pdf': |
|
|
elif result['type']=='application/pdf': |
|
|
result['thumbnailUrl'] = self.pdfthumbnail(result['name']) |
|
|
|
|
|
|
|
|
result['thumbnailUrl'] = self.pdfthumbnail(local_filename) |
|
|
elif result['type']=='image/svg+xml': |
|
|
elif result['type']=='image/svg+xml': |
|
|
result['thumbnailUrl'] = self.svgthumbnail(result['name']) |
|
|
|
|
|
|
|
|
result['thumbnailUrl'] = self.svgthumbnail(local_filename) |
|
|
elif result['type'].startswith('application/vnd'): |
|
|
elif result['type'].startswith('application/vnd'): |
|
|
result['thumbnailUrl'] = self.docthumbnail(result['name']) |
|
|
|
|
|
|
|
|
result['thumbnailUrl'] = self.docthumbnail(local_filename) |
|
|
elif result['type']=='application/x-blender': |
|
|
elif result['type']=='application/x-blender': |
|
|
result['thumbnailUrl'] = self.blendthumbnail(result['name']) |
|
|
|
|
|
|
|
|
result['thumbnailUrl'] = self.blendthumbnail(local_filename) |
|
|
else: |
|
|
else: |
|
|
result['thumbnailUrl'] = self.ExtMimeIcon(result['type']) |
|
|
result['thumbnailUrl'] = self.ExtMimeIcon(result['type']) |
|
|
|
|
|
|
|
@@ -531,11 +532,11 @@ class MediaUpload(MediaPath): |
|
|
sep='', |
|
|
sep='', |
|
|
name='', |
|
|
name='', |
|
|
media_table=self.media_table, |
|
|
media_table=self.media_table, |
|
|
uid=self.linked_id) + '/' + result['name'] |
|
|
|
|
|
|
|
|
uid=self.linked_id) + '/' + local_filename |
|
|
result['url'] = self.request.route_url('media_view', |
|
|
result['url'] = self.request.route_url('media_view', |
|
|
media_table=self.media_table, |
|
|
media_table=self.media_table, |
|
|
uid=self.linked_id, |
|
|
uid=self.linked_id, |
|
|
name=result['name']) |
|
|
|
|
|
|
|
|
name=local_filename) |
|
|
if DELETEMETHOD != 'DELETE': |
|
|
if DELETEMETHOD != 'DELETE': |
|
|
result['deleteUrl'] += '&_method=DELETE' |
|
|
result['deleteUrl'] += '&_method=DELETE' |
|
|
results.append(result) |
|
|
results.append(result) |
|
|