上传视频

@param inputStream 视频流
@param fileName    文件名
@param title       title
@param description 描述
@return 上传结果
179284
public Material addVideo(InputStream inputStream, String fileName, String title, String description) {
        String url = WxEndpoint.get("url.material.binary.upload");
        String desc = "{\"title\":\"%s\",\"introduction\":\"%s\"}";
        Map<String, String> form = new HashMap<>();
        form.put("description", String.format(desc, title, description));
        String response = wxClient.post(String.format(url, MediaType.video.name()), inputStream, fileName, form);

        Map<String, Object> result = JsonMapper.defaultMapper().json2Map(response);
        if (result.containsKey("media_id")) {
            return JsonMapper.defaultMapper().fromJson(response, Material.class);
        } else {
            logger.warn("image upload failed: {}", response);
            throw new WxRuntimeException(999, response);
        }
    }
910323
public CreateWebhookParams description(String description) {
        String value = (description==null) ? "" : description;
        parameters.add(new NameValuePair("description", value));
        return this;
    }
376732
public static Document inputStreamToDocument(InputStream is) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setExpandEntityReferences(false);
        factory.setIgnoringComments(false);
        factory.setIgnoringElementContentWhitespace(false);
        factory.setValidating(false);

        DocumentBuilder builder = factory.newDocumentBuilder();
        Document root = builder.parse(is);

        return root;
    }
169032
public CreateDocumentResponse createDocument(File file, String title, String format) {
        CreateDocumentRequest request = new CreateDocumentRequest();
        request.setFile(file);
        request.setTitle(title);
        request.setFormat(format);
        return this.createDocument(request);
    }
246380
public void load(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder out = new StringBuilder();
        String line;

        while ((line = reader.readLine()) != null) {
            out.append(line);
            out.append(System.lineSeparator());
        }

        setScriptText(out.toString());
    }
1238675
public Section readNextSection(String titleToLookFor) throws IOException {
    String title = null;
    StringBuilder keyBuilder = null;
    while (true) {
      String line = reader.readLine();
      if (line == null) {
        Preconditions.checkArgument(title == null, "missing end tag (%s)", title);
        return null;
      }
      if (keyBuilder == null) {
        Matcher m = BEGIN_PATTERN.matcher(line);
        if (m.matches()) {
          String curTitle = m.group(1);
          if (titleToLookFor == null || curTitle.equals(titleToLookFor)) {
            keyBuilder = new StringBuilder();
            title = curTitle;
          }
        }
      } else {
        Matcher m = END_PATTERN.matcher(line);
        if (m.matches()) {
          String endTitle = m.group(1);
          Preconditions.checkArgument(
              endTitle.equals(title), "end tag (%s) doesn't match begin tag (%s)", endTitle, title);
          return new Section(title, Base64.decodeBase64(keyBuilder.toString()));
        }
        keyBuilder.append(line);
      }
    }
  }
1234247
public Article createArticle(final String title, final String description, final String definedType) {
        HttpClient httpClient = null;
        try {
            final String method = "my_data/articles";
            // create an HTTP request to a protected resource
            final String url = getURL(endpoint, version, method);
            // create an HTTP request to a protected resource
            final HttpPost request = new HttpPost(url);
            Gson gson = new Gson();
            JsonObject payload = new JsonObject();
            payload.addProperty("title", title);
            payload.addProperty("description", description);
            payload.addProperty("defined_type", definedType);
            String jsonRequest = gson.toJson(payload);
            StringEntity entity = new StringEntity(jsonRequest);
            entity.setContentType(JSON_CONTENT_TYPE);
            request.setEntity(entity);

            // sign the request
            consumer.sign(request);

            // send the request
            httpClient = HttpClientBuilder.create().build();
            HttpResponse response = httpClient.execute(request);
            HttpEntity responseEntity = response.getEntity();
            String json = EntityUtils.toString(responseEntity);
            Article article = readArticleFromJson(json);
            return article;
        } catch (OAuthCommunicationException e) {
            throw new FigShareClientException("Failed to get articles: " + e.getMessage(), e);
        } catch (OAuthMessageSignerException e) {
            throw new FigShareClientException("Failed to get articles: " + e.getMessage(), e);
        } catch (OAuthExpectationFailedException e) {
            throw new FigShareClientException("Failed to get articles: " + e.getMessage(), e);
        } catch (ClientProtocolException e) {
            throw new FigShareClientException("Failed to get articles: " + e.getMessage(), e);
        } catch (IOException e) {
            throw new FigShareClientException("Failed to get articles: " + e.getMessage(), e);
        }
    }
551216
public MessageBuilder addAttachmentAsSpoiler(InputStream stream, String fileName) {
        delegate.addAttachment(stream, "SPOILER_" + fileName);
        return this;
    }
334748
public void showInfoHeader(String title, String description, String path, String locale, String iconClass) {

        getRpcProxy(I_CmsSitemapClientRpc.class).showInfoHeader(title, description, path, locale, iconClass);
    }
1059177
public static PdfLayer createTitle(String title, PdfWriter writer) {
        if (title == null)
            throw new NullPointerException("Title cannot be null.");
        PdfLayer layer = new PdfLayer(title);
        writer.registerLayer(layer);
        return layer;
    }
75306
public static String loadFile(String filename) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream is = classLoader.getResourceAsStream(filename);
        if (is == null) {
            throw new IllegalArgumentException("Unable to locate: " + filename);
        }
        return streamToString(is, filename);
    }
990258
public void setTitle(final String title) {
        if (this.title == null) {
            this.title = new Content();
        }
        this.title.setValue(title);
    }
317167
private void uploadThumbImage(StorageNode client, InputStream inputStream,
                                  String masterFilename, FastImageFile fastImageFile) {
        ByteArrayInputStream thumbImageStream = null;
        ThumbImage thumbImage = fastImageFile.getThumbImage();
        try {
            //生成缩略图片
            thumbImageStream = generateThumbImageStream(inputStream, thumbImage);
            // 获取文件大小
            long fileSize = thumbImageStream.available();
            // 获取配置缩略图前缀
            String prefixName = thumbImage.getPrefixName();
            LOGGER.error("获取到缩略图前缀{}", prefixName);
            StorageUploadSlaveFileCommand command = new StorageUploadSlaveFileCommand(thumbImageStream, fileSize,
                    masterFilename, prefixName, fastImageFile.getFileExtName());
            connectionManager.executeFdfsCmd(client.getInetSocketAddress(), command);

        } catch (IOException e) {
            LOGGER.error("upload ThumbImage error", e);
            throw new FdfsUploadImageException("upload ThumbImage error", e.getCause());
        } finally {
            IOUtils.closeQuietly(thumbImageStream);
        }
    }
1354312
public void setTitle(final String TITLE) {
        if (null == title) {
            _title = null == TITLE ? "" : TITLE;
            fireTileEvent(VISIBILITY_EVENT);
            fireTileEvent(REDRAW_EVENT);
        } else {
            title.set(TITLE);
        }
    }
716280
public void setInputStream(InputStream inputStream, long inputStreamLength) {
		// close last file when set a new inputStream
		if (this.isUploadFile){
			try{
				this.inputStream.close();
			}
			catch (Exception e){
			}
		}

		if (inputStream instanceof FDSProgressInputStream){
			this.inputStream = (FDSProgressInputStream) inputStream;
		}
		else {
			this.inputStream = new FDSProgressInputStream(inputStream, this.progressListener);
		}
		if (this.progressListener != null){
			this.progressListener.setTransferred(0);
			this.progressListener.setTotal(inputStreamLength);
		}
		this.isUploadFile = false;
		this.inputStreamLength = inputStreamLength;
	}
407673
private static InputStream inputStreamFromFile(String relativePathPrefix, String src) throws IOException {
        File file = getFile(relativePathPrefix, src);
        if (!file.exists()) {
            if (src.length() > 0 && src.charAt(0) == File.separatorChar) {
                file = getFile(relativePathPrefix, src.substring(1));
            }
            if (!file.exists()) {
                file = null;
            }
        } else if (!file.isFile() || !file.canRead()) {
            file = null;
        }
        if (file != null) {
            return new FileInputStream(file);
        }
        return null;
    }
725702
public void title(String title) {
        Validate.notNull(title);
        Element titleEl = getElementsByTag("title").first();
        if (titleEl == null) { // add to head
            head().appendElement("title").text(title);
        } else {
            titleEl.text(title);
        }
    }