android - How can I upload a picture taken with my camera? -


i'm trying send pictures have taken camera server, via ftp. i've coded portion of program responsible taking picture. next step send picture ftp server. how go doing this?

package de.android.datenuebertragung;  import java.io.bufferedoutputstream; import java.io.file; import java.io.fileoutputstream; import java.io.ioexception; import android.hardware.camera; import android.hardware.camera.picturecallback; import android.hardware.camera.shuttercallback; import android.os.environment; import android.util.log;  public class kameracallbacks implements shuttercallback, picturecallback {      private static final string tag = kameracallbacks.class.getsimplename();      public void onshutter() {         log.d(tag, "onshutter()");     }      public void onpicturetaken(byte[] data, camera camera) {         log.d(tag, "onpicturetaken()");         // in welchem verzeichnis soll die datei abgelegt werden?         file dir = environment                 .getexternalstoragepublicdirectory(environment.directory_pictures);          // ggf. verzeichnisse anlegen         dir.mkdirs();         // name der datei         file file = new file(dir, long.tostring(system.currenttimemillis())                 + ".jpg");         fileoutputstream fos = null;         bufferedoutputstream bos = null;         // datei gepuffert schreiben         try {             fos = new fileoutputstream(file);             bos = new bufferedoutputstream(fos);             bos.write(data);         } catch (ioexception e) {             log.e(tag, "onpicturetaken()", e);         } {             // ströme schließen - etwaige exceptions ignorieren             if (bos != null) {                 try {                     bos.close();                 } catch (ioexception e) {                 }             }             if (fos != null) {                 try {                     fos.close();                 } catch (ioexception e) {                 }             }             // live-vorschau neu starten             camera.startpreview();         }     } } 

here code found question how upload images ftp server within android app?. in program put following code?

simpleftp ftp = new simpleftp();  // connect ftp server on port 21. ftp.connect("server address", 21, "username", "pwd");  // set binary mode. ftp.bin();  // change new working directory on ftp server. ftp.cwd("path");  // upload files. ftp.stor(new file("your-file-path"));                // quit ftp server. ftp.disconnect(); 

or there better way not aware of upload picture ftp server.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -