我有问题
我尝试通过FTP将图像上传到我的服务器,但没有完成上传,出现错误,服务器显示的权重为0.1kb
代码:
try {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("zzz.zzz.zz.zzz"));
ftpClient.login("user", db_pass);
ftpClient.changeWorkingDirectory("/domains/dinosystems.ml/public_html/SavingDogs/Files/UserImgs/");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE, FTP.BINARY_FILE_TYPE);
ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
FileInputStream f = null;
if (ActivityCompat.checkSelfPermission(Registro_pet.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(Registro_pet.this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
f = new FileInputStream(i_file);
}
BufferedInputStream buffIn = new BufferedInputStream(f);
ftpClient.enterLocalPassiveMode();
Log.v("TRABAJANDO EN DIR: ", ftpClient.printWorkingDirectory());
ftpClient.makeDirectory(UID_u);
ftpClient.changeWorkingDirectory("/domains/dinosystems.ml/public_html/SavingDogs/Files/UserImgs/" + UID_u + "/");
Log.v("TRABAJANDO EN DIR: ", ftpClient.printWorkingDirectory());
Log.v("TRABAJANDO CON: ", archivo[archivo_space]);
ftpClient.storeFile(archivo[archivo_space], buffIn);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();
pass = true;
}
catch (Exception e)
{
e.printStackTrace();
pass = false;
}
错误es:
01-07 18:32:26.763 14577-14610/ml.dinosystems.savingdogs W/System.err: org.apache.commons.net.io.CopyStreamException: IOException caught while copying.
01-07 18:32:26.764 14577-14610/ml.dinosystems.savingdogs W/System.err: at org.apache.commons.net.io.Util.copyStream(Util.java:136)
at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:675)
at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:639)
at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:2030)
at ml.dinosystems.savingdogs.Registro_pet$upload_photo.doInBackground(Registro_pet.java:355)
at ml.dinosystems.savingdogs.Registro_pet$upload_photo.doInBackground(Registro_pet.java:327)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-07 18:32:26.765 14577-14610/ml.dinosystems.savingdogs W/System.err:
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:151)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
01-07 18:32:26.766 14577-14610/ml.dinosystems.savingdogs W/System.err:
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.apache.commons.net.io.Util.copyStream(Util.java:102)
... 11 more