与竞争对手相比,我已经阅读了很多使用CrossRider的积极见解,但我没有阅读任何与其任何限制相关的内容(功能,速度,与第三方服务的集成等).
我有这个代码将文件上传到我们的服务器(PHP).如何读取服务器的输出,而不仅仅是代码200或"ok",而是实际的JSON响应?
我见过使用InputStreamReader和BufferedReader的例子,但我不知道如何使用它们......
public String uploadFile(){
String result = "Result:";
HttpURLConnection connection = null;
DataOutputStream outputStream = null;
DataInputStream inputStream = null;
String pathToOurFile = "/storage/emulated/0/My Documents/My Recordings/Voice0007.aac";
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 1*1024*1024*1024;
try
{
FileInputStream fileInputStream = new FileInputStream(new File(pathToOurFile) );
URL url = new URL(SERVER_URL);
connection = (HttpURLConnection) url.openConnection();
// Allow Inputs & Outputs.
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
// Set HTTP method to …
Run Code Online (Sandbox Code Playgroud)