1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

Updated test with needed params

This commit is contained in:
davigonz 2016-12-15 09:27:14 +01:00
parent 576231023b
commit b9492966a5
3 changed files with 21 additions and 9 deletions

View File

@ -157,7 +157,12 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
File fileToUpload = upFolder.listFiles()[0]; File fileToUpload = upFolder.listFiles()[0];
String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
String mimeType = getString(R.string.sample_file_mimetype); 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.addDatatransferProgressListener(this);
uploadOperation.execute(mClient, this, mHandler); uploadOperation.execute(mClient, this, mHandler);
} }

View File

@ -249,10 +249,10 @@ public class TestActivity extends Activity {
public RemoteOperationResult uploadFile( public RemoteOperationResult uploadFile(
String storagePath, String remotePath, String mimeType String storagePath, String remotePath, String mimeType
) { ) {
return TestActivity.uploadFile(storagePath, remotePath, mimeType, mClient); return TestActivity.uploadFile(storagePath, remotePath, mimeType, mClient);
} }
/** Access to the library method to Upload a File /** Access to the library method to Upload a File
* @param storagePath * @param storagePath
* @param remotePath * @param remotePath
@ -264,14 +264,18 @@ public class TestActivity extends Activity {
public static RemoteOperationResult uploadFile( public static RemoteOperationResult uploadFile(
String storagePath, String remotePath, String mimeType, OwnCloudClient client String storagePath, String remotePath, String mimeType, OwnCloudClient client
) { ) {
String fileLastModifTimestamp = getFileLastModifTimeStamp(storagePath);
UploadRemoteFileOperation uploadOperation; UploadRemoteFileOperation uploadOperation;
if ((new File(storagePath)).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) { if ((new File(storagePath)).length() > ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) {
uploadOperation = new ChunkedUploadRemoteFileOperation( uploadOperation = new ChunkedUploadRemoteFileOperation(
storagePath, remotePath, mimeType storagePath, remotePath, mimeType, fileLastModifTimestamp
); );
} else { } else {
uploadOperation = new UploadRemoteFileOperation( uploadOperation = new UploadRemoteFileOperation(
storagePath, remotePath, mimeType storagePath, remotePath, mimeType, fileLastModifTimestamp
); );
} }
@ -381,5 +385,9 @@ public class TestActivity extends Activity {
return extractedFile; return extractedFile;
} }
private static String getFileLastModifTimeStamp (String storagePath) {
File file = new File(storagePath);
Long timeStampLong = file.lastModified()/1000;
return timeStampLong.toString();
}
} }

View File

@ -121,5 +121,4 @@ public class UploadFileTest extends RemoteTest {
} }
super.tearDown(); super.tearDown();
} }
} }