Anonymous avatar Anonymous committed 7755fc8

Upload.javaを変更

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

Comments (0)

Files changed (5)

Binary file modified.

Binary file modified.

Add a comment to this file

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

Binary file modified.

Binary file modified.

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

 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);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.