Example #1
0
    def file_name(self):
        file_name = self.data.get('file_name') \
            if self.has('file_name') else None

        # derive file name from headers
        if file_name is None and 'content_disposition' in self.headers:
            _, attrs = cgi.parse_header(self.headers['content_disposition'])
            file_name = attrs.get('filename')

        if file_name is None and self.source_path:
            file_name = os.path.basename(self.source_path)

        return make_filename(file_name)
Example #2
0
    def file_name(self):
        file_name = self.data.get('file_name') \
            if self.has('file_name') else None

        # derive file name from headers
        if file_name is None and 'content_disposition' in self.headers:
            _, attrs = cgi.parse_header(self.headers['content_disposition'])
            file_name = attrs.get('filename')

        if file_name is None and self.source_path:
            file_name = os.path.basename(self.source_path)

        return make_filename(file_name)
Example #3
0
    def file_name(self):
        file_name = self._file_name

        # derive file name from headers
        if file_name is None and 'content_disposition' in self.headers:
            _, attrs = cgi.parse_header(self.headers['content_disposition'])
            file_name = chomp(attrs.get('filename'))

        if file_name is None and self.source_path:
            file_name = os.path.basename(self.source_path)

        if file_name is None and self.source_url:
            parsed = urlparse(self.source_url)
            file_name = os.path.basename(parsed.path)

        return make_filename(file_name) or 'data'
Example #4
0
    def file_name(self):
        file_name = self._file_name

        # derive file name from headers
        if file_name is None and 'content_disposition' in self.headers:
            _, attrs = cgi.parse_header(self.headers['content_disposition'])
            file_name = chomp(attrs.get('filename'))

        if file_name is None and self.source_path:
            file_name = os.path.basename(self.source_path)

        if file_name is None and self.source_url:
            parsed = urlparse(self.source_url)
            file_name = os.path.basename(parsed.path)

        return make_filename(file_name) or 'data'
Example #5
0
 def file_name(self):
     return make_filename(self.file_title) or 'data'
Example #6
0
 def _get_local_mirror(self, meta):
     base = self._get_file_path(meta).split(os.path.sep)
     file_name = '-'.join((base[-2], base[-1]))
     return os.path.join(self.local_base, make_filename(file_name))