上传voice

@param inputStream voice
@param fileName    文件名
@return 上传结果
977318
public Material addVoice(InputStream inputStream, String fileName) {
        return upload(MediaType.voice, inputStream, fileName);
    }
543999
public int uploadFile(String name, java.io.File file) {
		FileDataBodyPart filePart = new FileDataBodyPart("source", file);
		// Work around for bug in cherrypy
		FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition
				.name(filePart.getName());
		builder.fileName(file.getName());
		builder.size(file.length());
		filePart.setFormDataContentDisposition(builder.build());

		FormDataMultiPart multiPart = new FormDataMultiPart();
		multiPart.bodyPart(filePart);
		multiPart.field("filename", name);

		Builder resource = getResourceFactory().getApiResource("/file/v2/")
				.entity(multiPart,
						new MediaType("multipart", "form-data", Collections
								.singletonMap("boundary", "AaB03x")));
		return resource.post(File.class).getId();
	}
1258304
public static String inputStreamToString(InputStream in) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		StringBuffer buffer = new StringBuffer();
		String line;
		while ((line = br.readLine()) != null) {
			buffer.append(line);
		}
		return buffer.toString();
	}
1292432
public void addFile(String path, InputStream inputStream) throws IOException {
    addFile(path, inputStream, null);
  }
1296212
public void setFileFromAJar(String fileName) {
        InputStream is = this.getClass().getResourceAsStream(fileName);
        if(is != null) {
            this.fileName = fileName;
            reader = new InputStreamReader(is);
        }
    }
519421
public InputStream getResourceAsStream(String fileName) {
		InputStream retval = super.getResourceAsStream(fileName);

		if (retval == null) {
			//String className = this.convertFileNameToClassName(fileName);
			//Object location = classResourceLocations.get(className);
			Object location = this.mixedResourceLocations.get(fileName);
			if (location == null) {
				return null;
			}

			byte[] data;
			try {
				data = getData(fileName, location);
			} catch (IOException ioe) {
				return null;
			}
			if (data == null) {
				return null;
			}
			return new ByteArrayInputStream(data);

		}
		return retval;
	}
1269773
public void initFromFile(final String filename) {
		try (final InputStream is = new FileInputStream(filename)) {
			init(is);
		} catch (IOException e) {
			initBackToDefaults();
		}
	}
889372
public static BaseResult addvoicetorecofortext(String accessToken, String voiceId, URI uri) {
        return addvoicetorecofortext(accessToken, voiceId, null, uri);
    }
1285256
public static BaseResult addvoicetorecofortext(String accessToken, String voiceId, String lang, File voice) {
        HttpPost httpPost = new HttpPost(BASE_URI + "/cgi-bin/media/voice/addvoicetorecofortext");
        FileBody bin = new FileBody(voice);
        HttpEntity reqEntity = MultipartEntityBuilder.create()
                .addPart("media", bin)
                .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(accessToken))
                .addTextBody("format", MediaType.voice_mp3.fileSuffix())
                .addTextBody("voice_id", voiceId)
                .addTextBody("lang", lang == null || lang.isEmpty() ? "zh_CN" : lang)
                .build();
        httpPost.setEntity(reqEntity);

        return LocalHttpClient.executeJsonResult(httpPost, BaseResult.class);
    }
133726
@Override
    public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
        LOG.log(Level.FINE, "getAudioInputStream(File file)");
        InputStream inputStream = new FileInputStream(file);
        try {
            return getAudioInputStream(inputStream);
        } catch (UnsupportedAudioFileException | IOException e) {
            inputStream.close();
            throw e;
        }
    }
782772
def _upload(self, files, voice_clip=False):
        
        file_dict = {"upload_{}".format(i): f for i, f in enumerate(files)}

        data = {"voice_clip": voice_clip}

        j = self._postFile(
            self.req_url.UPLOAD,
            files=file_dict,
            query=data,
            fix_request=True,
            as_json=True,
        )

        if len(j["payload"]["metadata"]) != len(files):
            raise FBchatException(
                "Some files could not be uploaded: {}, {}".format(j, files)
            )

        return [
            (data[mimetype_to_key(data["filetype"])], data["filetype"])
            for data in j["payload"]["metadata"]
        ]
691939
public static String readFile(String fileName) throws IOException {
        logger.entering(fileName);
        Preconditions.checkArgument(StringUtils.isNotBlank(fileName), "File name cannot be null (or) empty.");
        StringBuilder output = new StringBuilder();
        try (BufferedReader buffreader = new BufferedReader(new InputStreamReader(loadFile(fileName),
                Charset.forName("UTF-8")))) {
            String line = null;
            while ((line = buffreader.readLine()) != null) {
                output.append(line);
            }
        }
        logger.exiting(output);
        return output.toString();
    }
319618
public InputStreamReader getFileStream(String filename, String encoding)
			throws NoSuchPathException, UnmarshalException{
		try {
			return new InputStreamReader(new FileInputStream(filename), encoding);
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		} catch (UnsupportedEncodingException e){
			throw new UnmarshalException(e);
		}
	}
4513
private static InputStream getInputStreamFromFilename(String filename) {
        try {
            return new FileInputStream(filename);
        } catch (FileNotFoundException e) {
            log.debug("Error initializing RdfStreamReader, file '{}' not found", filename);
            // do not handle exception at construction time
            return null;
        }
    }
725646
@Override
    public AudioFileFormat getAudioFileFormat(InputStream inputStream) throws UnsupportedAudioFileException, IOException {
        LOG.log(Level.FINE, "getAudioFileFormat(InputStream inputStream)");
        try {
            if (!inputStream.markSupported()) {
                inputStream = new BufferedInputStream(inputStream);
            }
            inputStream.mark(MARK_LIMIT);
            return getAudioFileFormat(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED);
        } finally {
            inputStream.reset();
        }
    }
134637
public static String fileAsString(String filename) {
    File classpathFile = getClasspathFile(filename);
    return fileAsString(classpathFile);
  }
364434
private String readFileIntoString(String fileName,  InputStream is) throws IOException {
        FileInputStream stream = null;
        InputStreamReader reader = null;
        try {
            if (is != null) {
                reader = new InputStreamReader(is, charset);
            } else {
                stream = new FileInputStream(fileName);
                reader = new InputStreamReader(stream, charset);
            }
            
            return readStreamIntoString(reader);
        } finally {
            if (reader != null) {
                reader.close();
            }
            if (stream != null) {
                stream.close();
            }
        }
    }