(self, data, original_filename=None, username=None, attachment_id=None,
                    media_meta=None)
return True
This creates the auxmedia attachment with the downloaded data.
This creates the auxmedia attachment with the downloaded data.
This creates the auxmedia attachment with the downloaded data .
def attach_data(self, data, original_filename=None, username=None, attachment_id=None,
                    media_meta=None):
        """
        This creates the auxmedia attachment with the downloaded data.
        """
        self.last_modified = datetime.utcnow()

        if not attachment_id:
            attachment_id = self.file_hash

        if not self.blobs or attachment_id not in self.blobs:
            if not getattr(self, '_id'):
                # put_attchment blows away existing data, so make sure an id has been assigned
                # to this guy before we do it. This is the usual path; remote apps are the exception.
                self.save()
            self.put_attachment(
                data,
                attachment_id,
                content_type=self.get_mime_type(data, filename=original_filename),
                domain=SHARED_DOMAIN,
            )
        new_media = AuxMedia()
        new_media.uploaded_date = datetime.utcnow()
        new_media.attachment_id = attachment_id
        new_media.uploaded_filename = original_filename
        new_media.uploaded_by = username
        new_media.checksum = self.file_hash
        if media_meta:
            new_media.media_meta = media_meta
        self.aux_media.append(new_media)
        self.save()
        return True
def attach_data ( self , data , original_filename = None , username = None , attachment_id = None , media_meta = None ) : self . last_modified = datetime . utcnow ( ) if not attachment_id : attachment_id = self . file_hash if not self . blobs or attachment_id not in self . blobs : if not getattr ( self , '_id' ) : # put_attchment blows away existing data, so make sure an id has been assigned # to this guy before we do it. This is the usual path; remote apps are the exception. self . save ( ) self . put_attachment ( data , attachment_id , content_type = self . get_mime_type ( data , filename = original_filename ) , domain = SHARED_DOMAIN , ) new_media = AuxMedia ( ) new_media . uploaded_date = datetime . utcnow ( ) new_media . attachment_id = attachment_id new_media . uploaded_filename = original_filename new_media . uploaded_by = username new_media . checksum = self . file_hash if media_meta : new_media . media_meta = media_meta self . aux_media . append ( new_media ) self . save ( ) return True