Android在上传到ftp服务器之前调整图像文件大小

时间:2017-01-25 19:42:15

标签: java android bitmap upload ftp

我正在将图像文件上传到我的ftp服务器,但是我希望在将其上传到100-200kb之前减小文件大小,我搜索了一个答案,但我找不到适合我代码的文件。

这是我的上传代码(Takes gallery选择图像路径并上传它)

public void uploadingFilestoFtp() throws IOException {
    FTPClient ftpClient = null;

    try {
        ftpClient = new FTPClient();
        ftpClient.connect(InetAddress.getByName(host));

        if (ftpClient.login(username, password)) {

            ftpClient.enterLocalPassiveMode(); // important!
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
            String Location = Environment.getExternalStorageDirectory()
                    .toString();


            FileInputStream in = new FileInputStream(new File(imagePath));
            boolean result = ftpClient.storeFile("FileToSend.jpg", in);
            in.close();
            if (result)
                Log.v("upload result", "succeeded");
            ftpClient.logout();
            ftpClient.disconnect();

        }
    } catch (Exception e) {
        Log.v("count", "error");
        e.printStackTrace();
    }

}

0 个答案:

没有答案
相关问题