Subir imágenes con FTP en Android
¿Cómo puedo subir imágenes usando FTP en Android?
- ¿Cómo listar los directorios de ftp con android?
- ¿Cómo restaurar los datos de DDMS & Ftp Server?
- Servidor FTP de Android
- ¿Subir un archivo a un servidor FTP desde un teléfono Android?
- No se puede conectar a FTP en Gingerbread
- ¿Cómo descargar un archivo del servidor FTP al dispositivo Android?
- URL del navegador de Android URL
- Biblioteca FTP de Android
- Android: ¿Cómo puedo obtener el tamaño de archivo de un archivo FTP a través de FTPClient?
- FTP Subir y descargar en Android
- La carga de archivos zip por FTP está dañada a veces
- Seguimiento de FTP subir datos en android?
- FTPClient Subiendo archivo = SocketException: Conexión restablecida
Utilice SimpleFTP, simplemente agregue simpleftp.jar a su classpath e importe el paquete en cualquier clase que lo use: Descargue aquí
import org.jibble.simpleftp.*;
Asegúrese de utilizar el modo binario al cargar imágenes y similares, o pueden corromperse.
try { SimpleFTP ftp = new SimpleFTP(); // Connect to an FTP server on port 21. ftp.connect("ftp.somewhere.net", 21, "username", "password"); // Set binary mode. ftp.bin(); // Change to a new working directory on the FTP server. ftp.cwd("web"); // Upload some files. ftp.stor(new File("webcam.jpg")); ftp.stor(new File("comicbot-latest.png")); // You can also upload from an InputStream, eg ftp.stor(new FileInputStream(new File("test.png")), "test.png"); ftp.stor(someSocket.getInputStream(), "blah.dat"); // Quit from the FTP server. ftp.disconnect(); } catch (IOException e) { e.printStackTrace(); }
Esta fue toda la funcionalidad, por lo que no le permite descargar archivos!
Descargue la biblioteca FTP Jar desde aquí
public void sendFileViaFTP() { FTPClient ftpClient = null; try { ftpClient = new FTPClient(); ftpClient.connect(InetAddress.getByName("ftp.myserver.com")); if (ftpClient.login("myftpusername", "myftppass")) { ftpClient.enterLocalPassiveMode(); // important! ftpClient.setFileType(FTP.BINARY_FILE_TYPE); String Location = Environment.getExternalStorageDirectory() .toString(); String data = Location + File.separator + "FileToSend.txt"; FileInputStream in = new FileInputStream(new File(data)); boolean result = ftpClient.storeFile("FileToSend.txt", in); in.close(); if (result) Log.v("upload result", "succeeded"); ftpClient.logout(); ftpClient.disconnect(); } } catch (Exception e) { Log.v("count", "error"); e.printStackTrace(); } }
Esto funcionará con seguridad. Lo he hecho muchas veces.
- Problema del tipo de contenido de Retrofit-2
- Actividad y Fragmento Ciclos de Vida y Cambios de Orientación