diff --git a/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java index 09db872f..31cf1c79 100644 --- a/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -154,10 +154,15 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, private void startUpload() { File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); - File fileToUpload = upFolder.listFiles()[0]; + File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); String mimeType = getString(R.string.sample_file_mimetype); - UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType); + + // Get the last modification date of the file from the file system + Long timeStampLong = fileToUpload.lastModified()/1000; + String timeStamp = timeStampLong.toString(); + + UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp); uploadOperation.addDatatransferProgressListener(this); uploadOperation.execute(mClient, this, mHandler); } diff --git a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index ec4314f7..4bc107fe 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -249,10 +249,10 @@ public class TestActivity extends Activity { public RemoteOperationResult uploadFile( String storagePath, String remotePath, String mimeType ) { + return TestActivity.uploadFile(storagePath, remotePath, mimeType, mClient); } - /** Access to the library method to Upload a File * @param storagePath * @param remotePath @@ -264,14 +264,18 @@ public class TestActivity extends Activity { public static RemoteOperationResult uploadFile( String storagePath, String remotePath, String mimeType, OwnCloudClient client ) { - UploadRemoteFileOperation uploadOperation; + + String fileLastModifTimestamp = getFileLastModifTimeStamp(storagePath); + + UploadRemoteFileOperation uploadOperation; + if ((new File(storagePath)).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) { uploadOperation = new ChunkedUploadRemoteFileOperation( - storagePath, remotePath, mimeType + storagePath, remotePath, mimeType, fileLastModifTimestamp ); } else { uploadOperation = new UploadRemoteFileOperation( - storagePath, remotePath, mimeType + storagePath, remotePath, mimeType, fileLastModifTimestamp ); } @@ -381,5 +385,9 @@ public class TestActivity extends Activity { return extractedFile; } - + private static String getFileLastModifTimeStamp (String storagePath) { + File file = new File(storagePath); + Long timeStampLong = file.lastModified()/1000; + return timeStampLong.toString(); + } } diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java index 07854575..eeb6a24c 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UploadFileTest.java @@ -69,7 +69,7 @@ public class UploadFileTest extends RemoteTest { * Test Upload File without chunks */ public void testUploadFile() { - + String fullPath2Upload = mBaseFolderPath + UPLOAD_PATH; RemoteOperationResult result = mActivity.uploadFile( mFileToUpload.getAbsolutePath(), @@ -121,5 +121,4 @@ public class UploadFileTest extends RemoteTest { } super.tearDown(); } - }