new icons, new uploader
authorBartek Przybylski <bart.p.pl@gmail.com>
Tue, 15 May 2012 19:52:59 +0000 (21:52 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Tue, 15 May 2012 19:52:59 +0000 (21:52 +0200)
19 files changed:
AndroidManifest.xml
res/drawable-hdpi/ic_action_create_dir.png [new file with mode: 0644]
res/drawable-hdpi/ic_action_search.png
res/drawable-hdpi/ic_action_upload.png
res/drawable-ldpi/ic_action_create_dir.png [new file with mode: 0644]
res/drawable-ldpi/ic_action_search.png
res/drawable-ldpi/ic_action_upload.png
res/drawable-mdpi/ic_action_create_dir.png [new file with mode: 0644]
res/drawable-mdpi/ic_action_search.png
res/drawable-mdpi/ic_action_upload.png
res/drawable/main_header_bg.xml
res/drawable/split_action_bg.xml [new file with mode: 0644]
res/layout/progressbar_layout.xml [new file with mode: 0644]
res/menu/menu.xml
res/values/styles.xml
src/eu/alefzero/owncloud/files/services/FileUploader.java [new file with mode: 0644]
src/eu/alefzero/owncloud/files/services/OnUploadCompletedListener.java [new file with mode: 0644]
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
src/eu/alefzero/webdav/WebdavClient.java

index 39d9085..68def42 100644 (file)
         <activity android:name=".extensions.ExtensionsAvailableActivity"></activity>
         <activity android:name=".extensions.ExtensionsListActivity"></activity>\r
         <activity android:name=".ui.activity.AccountSelectActivity" android:uiOptions="none" android:label="@string/prefs_accounts"></activity>\r
         <activity android:name=".extensions.ExtensionsAvailableActivity"></activity>
         <activity android:name=".extensions.ExtensionsListActivity"></activity>\r
         <activity android:name=".ui.activity.AccountSelectActivity" android:uiOptions="none" android:label="@string/prefs_accounts"></activity>\r
+        <service android:name=".files.services.FileUploader" >\r
+        </service>\r
     </application>\r
 \r
 </manifest>
\ No newline at end of file
     </application>\r
 \r
 </manifest>
\ No newline at end of file
diff --git a/res/drawable-hdpi/ic_action_create_dir.png b/res/drawable-hdpi/ic_action_create_dir.png
new file mode 100644 (file)
index 0000000..1d1a03e
Binary files /dev/null and b/res/drawable-hdpi/ic_action_create_dir.png differ
index 720fc9b..a08722c 100644 (file)
Binary files a/res/drawable-hdpi/ic_action_search.png and b/res/drawable-hdpi/ic_action_search.png differ
index 0faf43b..61b1d71 100644 (file)
Binary files a/res/drawable-hdpi/ic_action_upload.png and b/res/drawable-hdpi/ic_action_upload.png differ
diff --git a/res/drawable-ldpi/ic_action_create_dir.png b/res/drawable-ldpi/ic_action_create_dir.png
new file mode 100644 (file)
index 0000000..49a226e
Binary files /dev/null and b/res/drawable-ldpi/ic_action_create_dir.png differ
index 9fd8157..7e4935f 100644 (file)
Binary files a/res/drawable-ldpi/ic_action_search.png and b/res/drawable-ldpi/ic_action_search.png differ
index 2369348..5cc5246 100644 (file)
Binary files a/res/drawable-ldpi/ic_action_upload.png and b/res/drawable-ldpi/ic_action_upload.png differ
diff --git a/res/drawable-mdpi/ic_action_create_dir.png b/res/drawable-mdpi/ic_action_create_dir.png
new file mode 100644 (file)
index 0000000..ce8cdef
Binary files /dev/null and b/res/drawable-mdpi/ic_action_create_dir.png differ
index 90cf335..7e4935f 100644 (file)
Binary files a/res/drawable-mdpi/ic_action_search.png and b/res/drawable-mdpi/ic_action_search.png differ
index 2d4ba56..b82399b 100644 (file)
Binary files a/res/drawable-mdpi/ic_action_upload.png and b/res/drawable-mdpi/ic_action_upload.png differ
index ba66621..04bdc46 100644 (file)
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android">
     <gradient
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android">
     <gradient
-        android:startColor="#1D2D44"
-        android:centerColor="#1D2D55" 
+        android:startColor="#1D2D44" 
         android:endColor="#1D2D44"
         android:angle="270"
      />
         android:endColor="#1D2D44"
         android:angle="270"
      />
diff --git a/res/drawable/split_action_bg.xml b/res/drawable/split_action_bg.xml
new file mode 100644 (file)
index 0000000..633340c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <gradient
+        android:startColor="#D0D0D0" 
+        android:endColor="#CCCCCC"
+        android:angle="90"
+     />
+</shape>
\ No newline at end of file
diff --git a/res/layout/progressbar_layout.xml b/res/layout/progressbar_layout.xml
new file mode 100644 (file)
index 0000000..f398d4c
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+  android:layout_width="fill_parent" android:layout_height="fill_parent"
+  android:padding="5dp">
+  <ImageView android:id="@+id/status_icon"
+    android:layout_width="wrap_content" android:layout_height="fill_parent"
+    android:layout_alignParentLeft="true" />
+
+  <RelativeLayout android:layout_width="fill_parent"
+    android:layout_height="fill_parent" android:layout_toRightOf="@id/status_icon">
+
+    <TextView android:id="@+id/status_text" android:layout_width="fill_parent"
+      android:layout_height="wrap_content" android:layout_alignParentTop="true" />
+    <ProgressBar android:id="@+id/status_progress"
+      android:layout_width="fill_parent" android:layout_height="wrap_content"
+      android:layout_below="@id/status_text"
+      android:progressDrawable="@android:drawable/progress_horizontal"
+      android:indeterminate="false" android:indeterminateOnly="false" />
+
+  </RelativeLayout>
+
+</RelativeLayout>
\ No newline at end of file
index f6a7db9..b630c7c 100644 (file)
@@ -2,7 +2,7 @@
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:id="@+id/startSync" android:title="Sync account" android:showAsAction="ifRoom" android:icon="@drawable/ic_action_refresh"></item><item android:title="Settings" android:icon="@android:drawable/ic_menu_preferences" android:id="@+id/settingsItem" android:showAsAction="never"></item>
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:id="@+id/startSync" android:title="Sync account" android:showAsAction="ifRoom" android:icon="@drawable/ic_action_refresh"></item><item android:title="Settings" android:icon="@android:drawable/ic_menu_preferences" android:id="@+id/settingsItem" android:showAsAction="never"></item>
-    <item android:id="@+id/createDirectoryItem" android:title="Create Directory" android:icon="@android:drawable/ic_menu_add" android:showAsAction="ifRoom"></item>
+    <item android:id="@+id/createDirectoryItem" android:title="Create Directory" android:icon="@drawable/ic_action_create_dir" android:showAsAction="ifRoom"></item>
     
     <item android:id="@+id/search" android:icon="@drawable/ic_action_search" android:showAsAction="ifRoom"></item>
     <item android:id="@+id/action_upload" android:icon="@drawable/ic_action_upload" android:showAsAction="ifRoom"></item>
     
     <item android:id="@+id/search" android:icon="@drawable/ic_action_search" android:showAsAction="ifRoom"></item>
     <item android:id="@+id/action_upload" android:icon="@drawable/ic_action_upload" android:showAsAction="ifRoom"></item>
index a09945e..8d5491f 100644 (file)
        <item name="android:background">@drawable/main_header_bg</item>
        <item name="background">@drawable/main_header_bg</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:background">@drawable/main_header_bg</item>
        <item name="background">@drawable/main_header_bg</item>
        <item name="android:textColor">#ffffff</item>
-   
        <item name="android:shadowColor">#222222</item>
        <item name="android:shadowRadius">1</item>
        <item name="android:shadowDy">1</item>
        <item name="android:shadowColor">#222222</item>
        <item name="android:shadowRadius">1</item>
        <item name="android:shadowDy">1</item>
+       <item name="android:backgroundSplit">@drawable/split_action_bg</item>
        </style>
        
        <!-- PopDownMenu -->
        </style>
        
        <!-- PopDownMenu -->
diff --git a/src/eu/alefzero/owncloud/files/services/FileUploader.java b/src/eu/alefzero/owncloud/files/services/FileUploader.java
new file mode 100644 (file)
index 0000000..323ae73
--- /dev/null
@@ -0,0 +1,153 @@
+package eu.alefzero.owncloud.files.services;
+
+import java.net.URLEncoder;
+
+import eu.alefzero.owncloud.AccountUtils;
+import eu.alefzero.owncloud.R;
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
+import eu.alefzero.owncloud.utils.OwnCloudVersion;
+import eu.alefzero.webdav.WebdavClient;
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Process;
+import android.util.Log;
+import android.webkit.MimeTypeMap;
+import android.widget.RemoteViews;
+import android.widget.Toast;
+
+public class FileUploader extends Service {
+
+  public static final String KEY_LOCAL_FILE = "LOCAL_FILE";
+  public static final String KEY_REMOTE_FILE = "REMOTE_FILE";
+  public static final String KEY_ACCOUNT = "ACCOUNT";
+  public static final String KEY_UPLOAD_TYPE = "UPLOAD_TYPE";
+  
+  public static final int UPLOAD_SINGLE_FILE = 0;
+  public static final int UPLOAD_MULTIPLE_FILES = 1;
+  
+  private static final String TAG = "FileUploader"; 
+  private NotificationManager mNotificationManager;
+  private Looper mServiceLooper;
+  private ServiceHandler mServiceHandler;
+  private AccountManager mAccountManager;
+  private Account mAccount;
+  private String[] mLocalPaths, mRemotePaths;
+  private boolean mResult;
+  private int mUploadType;
+  
+  @Override
+  public IBinder onBind(Intent arg0) {
+    return null;
+  }
+  
+  private final class ServiceHandler extends Handler {
+    public ServiceHandler(Looper looper) {
+      super(looper);
+    }
+    @Override
+    public void handleMessage(Message msg) {
+      uploadFile();
+      stopSelf(msg.arg1);
+    }
+  }
+  
+  @Override
+  public void onCreate() {
+    super.onCreate();
+    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+    HandlerThread thread = new HandlerThread("FileUploaderThread", Process.THREAD_PRIORITY_BACKGROUND);
+    thread.start();
+    mServiceLooper = thread.getLooper();
+    mServiceHandler = new ServiceHandler(mServiceLooper); 
+    mAccountManager = AccountManager.get(this);
+  }
+  
+  @Override
+  public int onStartCommand(Intent intent, int flags, int startId) {
+    if (!intent.hasExtra(KEY_ACCOUNT) && !intent.hasExtra(KEY_UPLOAD_TYPE)) {
+      Log.e(TAG, "Not enought data in intent provided");
+      return Service.START_NOT_STICKY;
+    }
+    mAccount = intent.getParcelableExtra(KEY_ACCOUNT);
+    mUploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1);
+    if (mUploadType == -1) {
+      Log.e(TAG, "Incorrect upload type provided");
+      return Service.START_NOT_STICKY;
+    }
+    if (mUploadType == UPLOAD_SINGLE_FILE) {
+      mLocalPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
+      mRemotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) };
+    } else { // mUploadType == UPLOAD_MULTIPLE_FILES
+      mLocalPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE);
+      mRemotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE);
+    }
+    
+    for (int i = 0; i < mRemotePaths.length; ++i)
+      mRemotePaths[i] = mRemotePaths[i].replace(' ', '+');
+    
+    if (mLocalPaths.length != mRemotePaths.length) {
+      Log.e(TAG, "Remote paths and local paths are not equal!");
+      return Service.START_NOT_STICKY;
+    }
+      
+    Message msg = mServiceHandler.obtainMessage();
+    msg.arg1 = startId;
+    mServiceHandler.sendMessage(msg);
+    
+    return Service.START_NOT_STICKY;
+  }
+
+  public void run() {
+    if (mResult) {
+      Toast.makeText(this, "Upload successfull", Toast.LENGTH_SHORT).show();
+    } else {
+      Toast.makeText(this, "No i kupa", Toast.LENGTH_SHORT).show();
+    }
+  }
+
+    public void uploadFile() {
+      String baseUrl = mAccountManager.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL),
+             ocVerStr = mAccountManager.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION);
+      OwnCloudVersion ocVer = new OwnCloudVersion(ocVerStr);
+      String webdav_path = AccountUtils.getWebdavPath(ocVer);
+      Uri ocUri = Uri.parse(baseUrl + webdav_path);
+      String username = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
+      String password = mAccountManager.getPassword(mAccount);
+      Notification notification = new Notification(eu.alefzero.owncloud.R.drawable.icon,
+                                                   "Uploading...", System.currentTimeMillis());
+      notification.flags |= Notification.FLAG_ONGOING_EVENT;
+      notification.contentView = new RemoteViews(getApplicationContext().getPackageName(),
+                                                 R.layout.progressbar_layout);
+      notification.contentView.setProgressBar(R.id.status_progress, mLocalPaths.length-1, 0, false);
+      notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
+      
+      mNotificationManager.notify(42, notification);
+
+      WebdavClient wc = new WebdavClient(ocUri);
+      wc.setCredentials(username, password);
+      
+      for (int i = 0; i < mLocalPaths.length; ++i) {
+        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(mLocalPaths[i].substring(mLocalPaths[i].lastIndexOf('.')+1));
+        mResult = false;
+        if (wc.putFile(mLocalPaths[i], mRemotePaths[i], mimeType)) {
+          mResult |= true;
+        }
+        notification.contentView.setProgressBar(R.id.status_progress, mLocalPaths.length-1, i+1, false);
+        
+        mNotificationManager.notify(42, notification);
+      }
+      //notification.contentView.setProgressBar(R.id.status_progress, mLocalPaths.length-1, mLocalPaths.length-1, false);
+      mNotificationManager.cancel(42);
+      run();
+    }
+}
diff --git a/src/eu/alefzero/owncloud/files/services/OnUploadCompletedListener.java b/src/eu/alefzero/owncloud/files/services/OnUploadCompletedListener.java
new file mode 100644 (file)
index 0000000..750e289
--- /dev/null
@@ -0,0 +1,8 @@
+package eu.alefzero.owncloud.files.services;
+
+public interface OnUploadCompletedListener extends Runnable {
+  
+  public boolean getUploadResult();
+  
+  public void setUploadResult(boolean result);
+}
index b87fd1d..46e9be9 100644 (file)
@@ -18,6 +18,9 @@
 \r
 package eu.alefzero.owncloud.ui.activity;\r
 \r
 \r
 package eu.alefzero.owncloud.ui.activity;\r
 \r
+import java.io.File;\r
+import java.net.URLEncoder;\r
+\r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
 import android.app.AlertDialog;\r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
 import android.app.AlertDialog;\r
@@ -55,8 +58,10 @@ import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
 import eu.alefzero.owncloud.datamodel.DataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.FileDataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
 import eu.alefzero.owncloud.datamodel.DataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.FileDataStorageManager;\r
 import eu.alefzero.owncloud.datamodel.OCFile;\r
+import eu.alefzero.owncloud.files.services.FileUploader;\r
 import eu.alefzero.owncloud.syncadapter.FileSyncService;\r
 import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
 import eu.alefzero.owncloud.syncadapter.FileSyncService;\r
 import eu.alefzero.owncloud.ui.fragment.FileListFragment;\r
+import eu.alefzero.owncloud.utils.OwnCloudVersion;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
@@ -164,6 +169,9 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
                \r
                requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
     setProgressBarIndeterminateVisibility(false);\r
                \r
                requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
     setProgressBarIndeterminateVisibility(false);\r
+    //if (getSupportFragmentManager().findFragmentById(R.id.fileList) == null)\r
+      setContentView(R.layout.files);\r
+    \r
        }\r
 \r
        @Override\r
        }\r
 \r
        @Override\r
@@ -245,8 +253,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
           IntentFilter f = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
           syncBroadcastRevceiver = new  SyncBroadcastReceiver();\r
           registerReceiver(syncBroadcastRevceiver, f);\r
           IntentFilter f = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
           syncBroadcastRevceiver = new  SyncBroadcastReceiver();\r
           registerReceiver(syncBroadcastRevceiver, f);\r
-          if (getSupportFragmentManager().findFragmentById(R.id.fileList) == null)\r
-            setContentView(R.layout.files);\r
           \r
           mDirectories = new CustomArrayAdapter<String>(this,\r
                R.layout.sherlock_spinner_dropdown_item);\r
           \r
           mDirectories = new CustomArrayAdapter<String>(this,\r
                R.layout.sherlock_spinner_dropdown_item);\r
@@ -261,28 +267,40 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
        }\r
            \r
         public void onActivityResult(int requestCode, int resultCode, Intent data) {\r
        }\r
            \r
         public void onActivityResult(int requestCode, int resultCode, Intent data) {\r
+          Log.e("ASD", requestCode + " " + resultCode);\r
      if (resultCode == RESULT_OK) {\r
          if (requestCode == ACTION_SELECT_FILE) {\r
      if (resultCode == RESULT_OK) {\r
          if (requestCode == ACTION_SELECT_FILE) {\r
-             Uri selectedImageUri = data.getData();\r
-\r
-             String filemanagerstring = selectedImageUri.getPath();\r
-\r
-             String selectedImagePath = getPath(selectedImageUri);\r
-\r
-             //DEBUG PURPOSE - you can delete this if you want\r
-             if(selectedImagePath!=null)\r
-                 System.out.println(selectedImagePath);\r
-             else System.out.println("selectedImagePath is null");\r
-             if(filemanagerstring!=null)\r
-                 System.out.println(filemanagerstring);\r
-             else System.out.println("filemanagerstring is null");\r
-\r
-             //NOW WE HAVE OUR WANTED STRING\r
-             if(selectedImagePath!=null)\r
-                 System.out.println("selectedImagePath is the right one for you!");\r
-             else\r
-                 System.out.println("filemanagerstring is the right one for you!");\r
+           Uri selectedImageUri = data.getData();\r
+\r
+           String filemanagerstring = selectedImageUri.getPath();\r
+           String selectedImagePath = getPath(selectedImageUri);\r
+           String filepath;\r
+\r
+           if(selectedImagePath!=null)\r
+               filepath = selectedImagePath;\r
+           else\r
+               filepath = filemanagerstring;\r
+             \r
+         if (filepath == null) {\r
+           Log.e("FileDisplay", "Couldnt resolve path to file");\r
+           return;\r
          }\r
          }\r
+         \r
+         Intent i = new Intent(this, FileUploader.class);\r
+         i.putExtra(FileUploader.KEY_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));\r
+         String remotepath = new String();\r
+         for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
+           remotepath += "/" + mDirectories.getItem(j);\r
+         }\r
+         if (!remotepath.endsWith("/")) remotepath += "/";\r
+         remotepath += new File(filepath).getName();\r
+         Log.e("ASD", remotepath+"");\r
+         \r
+         i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
+         i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
+         i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);\r
+         startService(i);\r
+       }\r
      }\r
         }\r
         \r
      }\r
         }\r
         \r
@@ -291,8 +309,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
        Cursor cursor = managedQuery(uri, projection, null, null, null);\r
        if(cursor!=null)\r
        {\r
        Cursor cursor = managedQuery(uri, projection, null, null, null);\r
        if(cursor!=null)\r
        {\r
-           //HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL\r
-           //THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA\r
            int column_index = cursor\r
            .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\r
            cursor.moveToFirst();\r
            int column_index = cursor\r
            .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\r
            cursor.moveToFirst();\r
index 1416d17..4b719fb 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;\r
 import org.apache.commons.httpclient.methods.HeadMethod;\r
 import org.apache.commons.httpclient.methods.PutMethod;\r
 import org.apache.commons.httpclient.methods.GetMethod;\r
 import org.apache.commons.httpclient.methods.HeadMethod;\r
 import org.apache.commons.httpclient.methods.PutMethod;\r
+import org.apache.commons.httpclient.methods.RequestEntity;\r
 import org.apache.commons.httpclient.params.HttpMethodParams;\r
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.http.HttpStatus;\r
 import org.apache.commons.httpclient.params.HttpMethodParams;\r
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.http.HttpStatus;\r
@@ -102,10 +103,14 @@ public class WebdavClient extends HttpClient {
                   String contentType) {
     boolean result = true;
 
                   String contentType) {
     boolean result = true;
 
-    try {
-      FileRequestEntity entity = new FileRequestEntity(new File(localFile), contentType);\r
-      PutMethod put = new PutMethod(mUri.toString() + remoteTarget.substring(1));\r
+    try {\r
+      Log.e("ASD", contentType+"");\r
+      File f = new File(localFile);
+      RequestEntity entity = new FileRequestEntity(f, contentType);\r
+      Log.e("ASD", f.exists()+" " + entity.getContentLength());\r
+      PutMethod put = new PutMethod(mUri.toString() + remoteTarget);\r
       put.setRequestEntity(entity);\r
       put.setRequestEntity(entity);\r
+      Log.d(TAG, "" + put.getURI().toString());\r
       int status = executeMethod(put);\r
       Log.d(TAG, "PUT method return with status "+status);
 
       int status = executeMethod(put);\r
       Log.d(TAG, "PUT method return with status "+status);