Returns the current download state for a download request.

@param downloadId
@return
341992
int query(int downloadId) {
		synchronized (mCurrentRequests) {
			for (DownloadRequest request : mCurrentRequests) {
				if (request.getDownloadId() == downloadId) {
					return request.getDownloadState();
				}
			}
		}
		return DownloadManager.STATUS_NOT_FOUND;
	}
254952
function _cmdAbortDownload(downloadId) {
    if (!pendingDownloads[downloadId]) {
        // This may mean the download already completed
        return false;
    } else {
        _endDownload(downloadId, Errors.CANCELED);
        return true;
    }
}
1196209
public static String getResourceInstitution(String resourceId)
	{
		Resource resource = getResource(resourceId);
    	return resource.getDataInstitution();
	}
223405
public Optional<SingularityRequestWithState> getSingularityRequestSimple(String requestId) {
    final Function<String, String> singularityApiRequestUri = (host) -> String.format(REQUEST_GET_SIMPLE_FORMAT, getApiBase(host), requestId);

    return getSingle(singularityApiRequestUri, "request-simple", requestId, SingularityRequestWithState.class);
  }
701181
public boolean getLotDownload(int id, File directory) {
        ClientResource resource = new ClientResource(Route.DOWNLOAD_LOT.url(id));
        resource.setChallengeResponse(this.auth.toChallenge());

        try {
            Representation repr = resource.get(MediaType.APPLICATION_ZIP);
            Disposition disposition = repr.getDisposition();

            File file = new File(directory, disposition.getFilename());
            FileOutputStream fos = new FileOutputStream(file);
            repr.write(fos);

            // Flush remaining buffer to output and close the stream
            fos.flush();
            fos.close();

            return true;
        } catch (IOException ex) {
            LEX4JLogger.log(Level.WARNING, "Could not write download to the FileOutputStream!");
            return false;
        }
    }
207199
private void checkResumableDownloadEnabled(int downloadId) {
		synchronized (mCurrentRequests) {
			for (DownloadRequest request : mCurrentRequests) {
				if (downloadId == -1 && !request.isResumable()) {
					Log.e("ThinDownloadManager",
							String.format(Locale.getDefault(), "This request has not enabled resume feature hence request will be cancelled. Request Id: %d", request.getDownloadId()));
				} else if ((request.getDownloadId() == downloadId && !request.isResumable())) {
					throw new IllegalStateException("You cannot pause the download, unless you have enabled Resume feature in DownloadRequest.");
				} else {
					//ignored, It can not be a scenario to happen.
				}
			}
		}
	}
3507
def download(self):
        
        if not self.can_update():
            self._tcex.handle_error(910, [self.type])

        return self.tc_requests.download(self.api_type, self.api_sub_type, self.unique_id)
195356
public DownloadMediaResponse download(String mediaId){
        DownloadMediaResponse response = new DownloadMediaResponse();
        String url = BASE_API_URL + "cgi-bin/media/get?access_token=" + config.getAccessToken() + "&media_id=" + mediaId;
        RequestConfig config = RequestConfig.custom().setConnectionRequestTimeout(NetWorkCenter.CONNECT_TIMEOUT).setConnectTimeout(NetWorkCenter.CONNECT_TIMEOUT).setSocketTimeout(NetWorkCenter.CONNECT_TIMEOUT).build();
        CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
        HttpGet get = new HttpGet(url);
        try{
            CloseableHttpResponse r = client.execute(get);
            if(HttpStatus.SC_OK == r.getStatusLine().getStatusCode()){
                InputStream inputStream = r.getEntity().getContent();
                Header[] headers = r.getHeaders("Content-disposition");
                if (null != headers && 0 != headers.length) {
                    Header length = r.getHeaders("Content-Length")[0];
                    response.setContent(inputStream, Integer.valueOf(length.getValue()));
                    response.setFileName(headers[0].getElements()[0].getParameterByName("filename").getValue());
                } else {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    StreamUtil.copy(inputStream, out);
                    String json = out.toString();
                    response = JSONUtil.toBean(json, DownloadMediaResponse.class);
                }
            }
        } catch (Exception e) {
            LOG.error("异常", e);
        }finally {
            try{
                client.close();
            }catch (IOException e){
                LOG.error("异常", e);
            }
        }
        return response;
    }
111088
public GetDocumentDownloadResponse getDocumentDownload(String documentId) {
        checkNotNull(documentId, "documentId should not be null.");
        GetDocumentDownloadRequest request = new GetDocumentDownloadRequest();
        request.setDocumentId(documentId);
        InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC, request.getDocumentId());
        internalRequest.addParameter("download", null);
        GetDocumentDownloadResponse response;
        try {
            response = this.invokeHttpClient(internalRequest, GetDocumentDownloadResponse.class);
        } finally {
            try {
                internalRequest.getContent().close();
            } catch (Exception e) {
                // ignore exception
            }
        }

        return response;
    }
1189209
def status(self):
        ''''''
        if self.download is None:
            return "Not started"

        transferred = self.download - self.prev_download
        self.prev_download = self.download
        now = time.time()
        interval = now - self.last_status_time
        self.last_status_time = now
        return("DFLogger: %(state)s Rate(%(interval)ds):%(rate).3fkB/s "
               "Block:%(block_cnt)d Missing:%(missing)d Fixed:%(fixed)d "
               "Abandoned:%(abandoned)d" %
               {"interval": interval,
                "rate": transferred/(interval*1000),
                "block_cnt": self.last_seqno,
                "missing": len(self.missing_blocks),
                "fixed": self.missing_found,
                "abandoned": self.abandoned,
                "state": "Inactive" if self.stopped else "Active"})
246906
public function download($id)
    {
        $file = LocalFile::getByIdentifier($id);
        return response()->download($file->getAbsolutePath(), $file->getDownloadName());
    }
96373
public function getLogFromId( $download_id){
        $logService = sprintf( self::API_DOWNLOAD_LOG, $download_id);
        $rest = $this->getService( $logService);
        $rest->GET();

        return $rest->getResult();
    }
864371
public function deleteFromId( $download_id){
        $rest = $this->getService( self::API_DOWNLOAD . $download_id);
        $rest->DELETE();

        return $rest->getSuccess();
    }
886398
def download(self, torrent_id, directory, filename) :
        
        return self.call('torrents/download/%s' % torrent_id, params={'filename' : filename, 'directory' : directory})
931332
public function download($mediaId)
    {
        $response = $this->curl->post(self::DOWNLOAD.$this->access_token, json_encode([
                    'media_id' => $mediaId,
                ]
            )
        );
        $is_json = json_decode($response);
        if ($is_json) {
            return Response::json($is_json);
        } else {
            return $response;
        }
    }
1281741
public function emptyBlackListFromDownloadId( $downloadTaskId) {
        $service = sprintf( self::API_DOWNLOAD_ITEM_BLACKLIST_EMPTY, $downloadTaskId);
        $rest = $this->getService( $service);
        $rest->DELETE();

        return $rest->getSuccess();
    }
1338332
public static DownloadResponse downloadFile(Drive drive, String fileId) throws IOException {
	  Get request = drive.files().get(fileId).setAlt("media");
	  String contentType = request.executeUsingHead().getContentType();
	  if (StringUtils.isNotBlank(contentType)) {
  	  try (InputStream inputStream = request.executeAsInputStream()) {
	      return new DownloadResponse(contentType, IOUtils.toByteArray(inputStream));
      }
	  }
	  
	  return null;
	}