mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Updated test with needed params
This commit is contained in:
parent
576231023b
commit
b9492966a5
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user