Commits

myuhe  committed f29b4e5

外部jar追加、postまわり修正

  • Participants
  • Parent commits 7755fc8

Comments (0)

Files changed (8)

 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="lib" path="/home/yuhei/workspace/androizou/lib/apache-mime4j-0.6.jar"/>
+	<classpathentry kind="lib" path="/home/yuhei/workspace/androizou/lib/httpmime-4.0.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

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 lib/apache-mime4j-0.6.jar

Binary file added.

File lib/httpmime-4.0.jar

Binary file added.

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

-package org.homelinux.sheephead.androizou;
+package org.homelinux.sheephead.androizou;vvvvv
 
 import java.io.File;
+import java.io.IOException;
 
 import org.apache.http.HttpRequest;
+import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.FileBody;
 import org.apache.http.impl.client.DefaultHttpClient;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Environment;
 import android.util.Log;
 
 public class Upload extends Activity {
     private static final String TAG = "Logact";
-
+    
+    
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.upload);
         final Uri uri =  this.getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
         Log.d(TAG,uri.toString());
         
+                
+        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);
+//      送信
+        try {
+            client.execute(post);
+        } catch (ClientProtocolException e) {
+            // TODO 自動生成された catch ブロック
+            Log.d(TAG,"post Protocol error");
+            e.printStackTrace();
+        } catch (IOException e) {
+            // TODO 自動生成された catch ブロック
+            Log.d(TAG,"post IO error");
+            e.printStackTrace();
+        }
         
+ 
         
         
-        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);
+//          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();