下载媒体文件
@param mediaId 媒体ID
@return 下载结果
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;
    }
937876
public String getMimeType(final String fileId) {
		FileWidgetUpload fileWidget = getFile(fileId);
		if (fileWidget != null) {
			return FileUtil.getFileMimeType(fileWidget.getFile());
		}
		return null;
	}
86963
public static Observable<String> getPathFromUriForMediaDocument(final Context context,
      final Uri mediaUri, final String mediaDocumentId) {
    return Observable.fromCallable(new Func0<String>() {
      @Override
      public String call() {
        String pathFound = null;
        Cursor cursor = context.getContentResolver()
            .query(mediaUri, null, Constants.ID_COLUMN_VALUE + " =?",
                new String[] { mediaDocumentId }, null);
        if (cursor != null) {
          if (cursor.moveToFirst()) {
            pathFound =
                cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
          }
          cursor.close();
          logDebug("Path found:" + pathFound);
        }
        return pathFound;
      }
    });
  }
1014537
public function getMaterial($media_id) {
		$data = $this->getData('/cgi-bin/material/get_material', [
			'access_token' => $this->getAccessToken(),
		], Json::encode(['media_id' => $media_id]));

		return $this->errcode == 0 ? (isset($data['content']) && isset($data['extension']) ? $this->saveFile($data) : $data) : null;
	}
597490
public MpNews getMpNews(String mediaId) {
        String url = WxEndpoint.get("url.material.mpnews.get");

        String json = String.format("{\"media_id\":\"%s\"}", mediaId);
        logger.info("get mpnews: {}", json);
        String response = wxClient.post(url, json);
        return JsonMapper.defaultMapper().fromJson(response, MpNews.class);
    }
327162
def download_permanent_media(self, media_id):
        
        return requests.post(
            url="https://api.weixin.qq.com/cgi-bin/material/get_material",
            params={"access_token": self.token},
            data=_json.dumps({
                "media_id": media_id
            }, ensure_ascii=False).encode("utf-8")
        )
1129556
public function get1($mediaId)
    {
        /** @var \yii\httpclient\Response $response */
        $response = $request = $this->getHttpClient()->createRequest()
            ->setUrl([
                self::API_GET,
                'media_id' => $mediaId
            ])
            ->setMethod('GET')
            ->send();
        if ($response->isOk) {

        }
//        foreach ($response->getHeader('Content-Type') as $mime) {
//            if (preg_match('/(image|video|audio)/i', $mime)) {
//                return $response->getBody();
//            }
//        }
//
//        $json = $this->getHttp()->parseJSON($response);
//
//        // XXX: 微信开发这帮混蛋，尼玛文件二进制输出不带header，简直日了!!!
//        if (!$json) {
//            return $response->getBody();
//        }
//
//        $this->checkAndThrow($json);

        return $json;
    }
223266
public function getStream($mediaId)
    {
        $response = $request = $this->getHttpClient()->createRequest()
            ->setUrl([
                self::API_GET,
                'media_id' => $mediaId
            ])
            ->setMethod('GET')
            ->send();
        if ($response->isOk) {
            $json = json_decode($response->content, true);
            if (JSON_ERROR_NONE === json_last_error()) {
                $this->checkAndThrow($json);
            }
        }
        return $response->content;
    }
51772
public MediaItem getMediaItem(String id) {
		
		DailyMotionUrl url = new DailyMotionUrl(requestPrefix + id);
		
		HttpRequest request;
		try {
			request = requestFactory.buildGetRequest(url);
			DailyMotionVideo video = request.execute().parseAs(DailyMotionVideo.class);
			
			if(video != null) {
				MediaItem mediaItem = new DailyMotionMediaItem(video);
				return mediaItem;
			}
			
		} catch (Exception e) {
			
		}

		return null;
	}
934082
public static MaterialGetResult get_material(String access_token,String media_id){
		HttpUriRequest httpUriRequest = RequestBuilder.post()
					.setHeader(jsonHeader)
					.setUri(BASE_URI+"/cgi-bin/material/get_material")
					.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
					.setEntity(new StringEntity("{\"media_id\":\""+media_id+"\"}",Charset.forName("utf-8")))
					.build();
		return LocalHttpClient.execute(httpUriRequest,BytesOrJsonResponseHandler.createResponseHandler(MaterialGetResult.class));
	}
695635
public com.google.api.ads.adwords.axis.v201809.cm.Media getMedia() {
        return media;
    }
624324
public function assignMedia($mediaId)
    {
        $this->getLogger()->info('Assigning media ID ' . json_encode($mediaId) . ' To display Group ID ' . $this->displayGroupId);
        $this->doPost('/displaygroup/' . $this->displayGroupId . '/media/assign', [
            'mediaId' => $mediaId
            ]);

        return $this;
    }
146071
protected function getPreviewsFromFileVersion($mediaId, $fileVersion, $locale)
    {
        $title = '';
        /*
         * @var FileVersionMeta
         */
        foreach ($fileVersion->getMeta() as $key => $meta) {
            if ($meta->getLocale() == $locale) {
                $title = $meta->getTitle();
                break;
            } elseif (0 == $key) { // fallback title
                $title = $meta->getTitle();
            }
        }

        $mediaFormats = $this->formatManager->getFormats(
            $mediaId,
            $fileVersion->getName(),
            $fileVersion->getStorageOptions(),
            $fileVersion->getVersion(),
            $fileVersion->getSubVersion(),
            $fileVersion->getMimeType()
        );

        foreach ($mediaFormats as $formatName => $formatUrl) {
            if ($formatName == $this->collectionPreviewFormat) {
                return [
                    'url' => $formatUrl,
                    'title' => $title,
                ];
                break;
            }
        }

        return [];
    }
1122740
public function fetchPermanentAudio ($mediaID, $into = null)
    {
        return new Downloaded\Audio($mediaID, $this->doPermanentFetchToStream($mediaID, $into));
    }
241915
public function delete($mediaId)
    {
        return $this->http->get(self::API_FOREVER_DELETE, array('media_id' => $mediaId, 'agentid' => $this->agentId));
    }
769381
public function getStream($mediaId)
    {
        $response = $this->getHttp()->get(self::API_GET, ['media_id' => $mediaId]);

        return $response->getBody();
    }
666574
public function getUsage($mediaId)
    {
        $this->mediaId = $mediaId;

        $this->getLogger()->info('Getting media usage report ' . $mediaId . ' for Displays');
        $response = $this->doGet('/library/usage/' . $mediaId );

        $this->getLogger()->debug('Passing the response to Hydrate');
        return $this->hydrate($response);
    }