1. myuhe
  2. Androizou

Commits

myuhe  committed 7755fc8

Upload.javaを変更

multipart-postはまだうまくいかない。

  • Participants
  • Parent commits 3818bec
  • Branches default

Comments (0)

Files changed (5)

File bin/androizou.apk

Binary file modified.

File bin/classes.dex

Binary file modified.

File bin/org/homelinux/sheephead/androizou/Upload.class

Binary file modified.

File bin/resources.ap_

Binary file modified.

File src/org/homelinux/sheephead/androizou/Upload.java

View file
 package org.homelinux.sheephead.androizou;
 
+import java.io.File;
+
+import org.apache.http.HttpRequest;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.DefaultHttpClient;
         final Uri uri =  this.getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
         Log.d(TAG,uri.toString());
         
-        HttpClient httpClient = new DefaultHttpClient();
-        HttpPost post = new HttpPost(URL);
-        MultipartEntity entity 
+        
+        
+        
+        DefaultHttpClient client = new DefaultHttpClient();
+//送り先 先は先で適当にPHPで処理しておく
+HttpPost post = new HttpPost("http://192.168.11.111/hoge.php");
+MultipartEntity entity = new MultipartEntity();
+post.setEntity(entity);
+//↓送りたいファイルのセット
+FileBody fileBody = new FileBody(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/hoge.txt"));
+entity.addPart("file", fileBody);
+//送信
+client.execute(post);
+        
+        
+        
+        
+          File f = new File("/path/fileToUpload.txt");
+  HttpRequest request = new HttpRequest("http://host/some_path");
+  Part[] parts = {
+      new StringPart("param_name", "value"),
+      new FilePart(f.getName(), f)
+  };
+  filePost.setEntity(
+      new MultipartRequestEntity(parts, filePost.getParams())
+      );
+  HttpClient client = new HttpClient();
+  int status = client.executeMethod(filePost);
+
+        
+        //HttpClient httpClient = new DefaultHttpClient();
+        //HttpPost post = new HttpPost(URL);
+        //MultipartEntity entity 
         
 //        	private void SetIDAndPass( boolean bCreate){
 //		updateButton.setClickable(false);