Get a file download object that contains temporary url settings needed to download the contents of a file.
        :param file_id: str: uuid of the file
        :return: FileDownload
191461
def get_file_download(self, file_id):
        
        return self._create_item_response(
            self.data_service.get_file_url(file_id),
            FileDownload
        )
1172293
def download_file(response)
      tmp_file = Tempfile.new '', Configuration.temp_folder_path
      content_disposition = response.headers['Content-Disposition']
      if content_disposition
        filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
        path = File.join File.dirname(tmp_file), filename
      else
        path = tmp_file.path
      end
      # close and delete temp file
      tmp_file.close!

      File.open(path, 'w') { |file| file.write(response.body) }
      Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
                                "folder for further processing and delete the temp afterwards"
      File.new(path)
    end
1006836
def download_to_file(self, file):
        
        con = ConnectionManager().get_connection(self._connection_alias)
        return con.download_to_file(self.file, file, append_base_url=False)
336442
def _get_inbound_stream(self, stream_id):
        
        if stream_id not in self._inbound_streams:
            self._inbound_streams[stream_id] = InboundStream()
        return self._inbound_streams[stream_id]
65197
def file_id(self):
        
        if self.type.lower() == "directory":
            return None
        if self.file_uuid is None:
            raise exceptions.MetsError(
                "No FILEID: File %s does not have file_uuid set" % self.path
            )
        if self.is_aip:
            return os.path.splitext(os.path.basename(self.path))[0]
        return utils.FILE_ID_PREFIX + self.file_uuid
112067
def get_download_url(self, instance, default=None):
        
        download = default
        # calculate the download url
        download = "{url}/@@download/{fieldname}/{filename}".format(
            url=api.get_url(instance),
            fieldname=self.get_field_name(),
            filename=self.get_filename(instance),
        )
        return download
41082
def _download_files(self, client, flow_id):
    
    output_file_path = os.path.join(
        self.output_path, '.'.join((flow_id, 'zip')))

    if os.path.exists(output_file_path):
      print('{0:s} already exists: Skipping'.format(output_file_path))
      return None

    flow = client.Flow(flow_id)
    file_archive = flow.GetFilesArchive()
    file_archive.WriteToFile(output_file_path)

    # Unzip archive for processing and remove redundant zip
    fqdn = client.data.os_info.fqdn.lower()
    client_output_file = os.path.join(self.output_path, fqdn)
    if not os.path.isdir(client_output_file):
      os.makedirs(client_output_file)

    with zipfile.ZipFile(output_file_path) as archive:
      archive.extractall(path=client_output_file)
    os.remove(output_file_path)

    return client_output_file
878438
def filename(self, type_, id_):
        
        profile = self.connection.profile
        return os.path.join(self.directory, profile, type_, str(id_))
751281
def get(self, file_id: Union[str, bson.ObjectId]) -> [typing.BinaryIO, str, datetime.datetime]:
        
        if isinstance(file_id, str):
            file_id = bson.ObjectId(file_id)
        file = self._fs.get(file_id)
        return file, file.filename, file.upload_date
501949
def download(path, default_ext=None):
    
    key = "DOWNLOAD:{}".format(path)
    if not config.UPDATE and FILECACHE.get(key):
        return FILECACHE.get(key).decode('utf-8')

    config.LOGGER.info("\tDownloading {}".format(path))

    # Write file to temporary file
    with tempfile.TemporaryFile() as tempf:
        hash = write_and_get_hash(path, tempf)
        tempf.seek(0)

        # Get extension of file or default if none found
        extension = os.path.splitext(path)[1][1:].lower()
        if extension not in [key for key, value in file_formats.choices]:
            if default_ext:
                extension = default_ext
            else:
                raise IOError("No extension found: {}".format(path))

        filename = '{0}.{ext}'.format(hash.hexdigest(), ext=extension)

        copy_file_to_storage(filename, tempf)

        FILECACHE.set(key, bytes(filename, "utf-8"))

        return filename
54941
public String getFileThumbnailUrl(final String fileId) {
		FileWidgetUpload file = getFile(fileId);
		if (file == null) {
			return null;
		}

		// Check static resource
		Image thumbnail = file.getThumbnail();
		if (thumbnail instanceof InternalResource) {
			return ((InternalResource) thumbnail).getTargetUrl();
		}

		Environment env = getEnvironment();
		Map<String, String> parameters = env.getHiddenParameters();
		parameters.put(Environment.TARGET_ID, getTargetId());

		if (Util.empty(file.getThumbnailCacheKey())) {
			// Add some randomness to the URL to prevent caching
			String random = WebUtilities.generateRandom();
			parameters.put(Environment.UNIQUE_RANDOM_PARAM, random);
		} else {
			// Remove step counter as not required for cached content
			parameters.remove(Environment.STEP_VARIABLE);
			parameters.remove(Environment.SESSION_TOKEN_VARIABLE);
			// Add the cache key
			parameters.put(Environment.CONTENT_CACHE_KEY, file.getThumbnailCacheKey());
		}

		// File id
		parameters.put(FILE_UPLOAD_ID_KEY, fileId);

		// Thumbnail flag
		parameters.put(FILE_UPLOAD_THUMB_NAIL_KEY, "Y");

		// The targetable path needs to be configured for the portal environment.
		String url = env.getWServletPath();

		// Note the last parameter. In javascript we don't want to encode "&".
		return WebUtilities.getPath(url, parameters, true);
	}
761263
def download
      return io if io.is_a?(Tempfile)

      Tempfile.new(id, binmode: true).tap do |tempfile|
        IO.copy_stream(io, tempfile)
        tempfile.rewind
        tempfile.fsync
      end
    end
1163385
def get_file(self, file_key):
		'''
		'''
		uri = '/'.join([
						self.api_uri,
						self.files_suffix,
						file_key
						])

		return self._req('get', uri)
741435
def file_id_to_file_name(file_id):
        
        if len(file_id) == 40 and re.match("^[a-f0-9]+$", file_id):
            return file_id
        # prefix with "re_" to avoid name collision with real fileids
        return "re_{}".format(hashlib.sha1(file_id).hexdigest())
634694
def get_file_by_id(self, file_id):
        
        file_ref = self.objects[file_id]
        if not isinstance(file_ref, PBXFileReference):
            return None
        return file_ref
1050900
def get_file_ids(object):
    """"""
    import MOPdbaccess
    mysql = MOPdbaccess.connect('cfeps','cfhls',dbSystem='MYSQL')
    cfeps=mysql.cursor()
    sql="SELECT file_id FROM measure WHERE provisional LIKE %s"
    cfeps.execute(sql,(object, ))
    file_ids=cfeps.fetchall()

    return (file_ids)
1186563
def download(self, uri, file_path):
        
        with open(file_path, 'wb') as file:
            return self._connection.download_to_stream(file, uri)