def getThumbUrl(self, media_type, media_id, max_width=None, max_height=None): """ Get the URL to an image representation of the media. For images, this may be used for getting a thumbnail. Specify max width and height in that case. Otherwise you'll probably just get a generic file image. """ return mProject.getAttachmentThumbUrl(media_type, media_id, 'small')
def newFile(self): """ Controller for the ``/create/attachment`` endpoint. **Parameters:** ``qqfile`` (required) Contains the file to be uploaded. ``max_width``/``max_height`` The maximum width and height to use for the thumbnail image. """ # Upload the file to the server file_info = self.uploadFile() if not file_info['id']: log.error("*** createProject.newFile: Failed to create file.") return self.json({ 'success' : False }) # Save an attachment record to the database attachment_id = mProject.createAttachment(self.db, media_id=file_info['id'], media_type=file_info['type'], title=file_info['name']) if attachment_id is None: log.error(("*** createProject.newFile: Failed insert row for file " "with info %s into the attachments table." % file_info)) return self.json({ 'success' : False }) return self.json({ 'id' : attachment_id, 'media_id' : file_info['id'], 'media_type' : file_info['type'], 'title' : file_info['name'], 'small_thumb_url' : mProject.getAttachmentThumbUrl(file_info['type'], file_info['id'], 'small'), 'medium_thumb_url' : mProject.getAttachmentThumbUrl(file_info['type'], file_info['id'], 'medium'), 'large_thumb_url' : mProject.getAttachmentThumbUrl(file_info['type'], file_info['id'], 'large'), 'success' : (file_info['id'] != None) #TODO add url })