get filesize
This commit is contained in:
parent
ac1858ba2b
commit
6729688096
2 changed files with 22 additions and 5 deletions
|
@ -1,17 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<targetSelectedWithDropDown>
|
<runningDeviceTargetSelectedWithDropDown>
|
||||||
<Target>
|
<Target>
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
<type value="RUNNING_DEVICE_TARGET" />
|
||||||
<deviceKey>
|
<deviceKey>
|
||||||
<Key>
|
<Key>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_24.avd" />
|
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_31.avd" />
|
||||||
</Key>
|
</Key>
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</targetSelectedWithDropDown>
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2022-09-17T22:23:51.793318Z" />
|
<timeTargetWasSelectedWithDropDown value="2022-09-21T18:41:42.025960Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -16,6 +16,9 @@ import com.amazonaws.services.s3.AmazonS3;
|
||||||
import com.amazonaws.services.s3.AmazonS3Client;
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
import com.amazonaws.services.s3.S3ClientOptions;
|
import com.amazonaws.services.s3.S3ClientOptions;
|
||||||
import com.amazonaws.services.s3.model.Bucket;
|
import com.amazonaws.services.s3.model.Bucket;
|
||||||
|
import com.amazonaws.services.s3.model.ListObjectsRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ObjectListing;
|
||||||
|
import com.amazonaws.services.s3.model.S3ObjectSummary;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,6 +32,9 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
ProgressBar simpleProgressBar;
|
ProgressBar simpleProgressBar;
|
||||||
TextView filesize, filesizeinfo;
|
TextView filesize, filesizeinfo;
|
||||||
boolean isobject, isfolder;
|
boolean isobject, isfolder;
|
||||||
|
long totalSize = 0;
|
||||||
|
int totalItems = 0;
|
||||||
|
ListObjectsRequest orequest;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -64,6 +70,7 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
//Your code goes here
|
//Your code goes here
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
isobject = false;
|
isobject = false;
|
||||||
|
orequest = new ListObjectsRequest().withBucketName(bucket).withMaxKeys(8000);
|
||||||
} else {
|
} else {
|
||||||
isobject = true;
|
isobject = true;
|
||||||
if (object.endsWith("/")) {
|
if (object.endsWith("/")) {
|
||||||
|
@ -71,7 +78,16 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
isfolder = false;
|
isfolder = false;
|
||||||
}
|
}
|
||||||
|
orequest = new ListObjectsRequest().withBucketName(bucket).withPrefix(object).withMaxKeys(8000);
|
||||||
}
|
}
|
||||||
|
ObjectListing result = s3client.listObjects(orequest);
|
||||||
|
do {
|
||||||
|
for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
|
||||||
|
totalSize += objectSummary.getSize();
|
||||||
|
totalItems++;
|
||||||
|
}
|
||||||
|
result = s3client.listNextBatchOfObjects (result);
|
||||||
|
} while (result.isTruncated());
|
||||||
|
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
@ -87,6 +103,7 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
filesizeinfo.setText(getResources().getString(R.string.bucket_size));
|
filesizeinfo.setText(getResources().getString(R.string.bucket_size));
|
||||||
}
|
}
|
||||||
|
filesize.setText(Long.toString(totalSize));
|
||||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue