MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / pickFile

Function pickFile

apps/toolbox/src/pages/fs-helper.ts:103–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101}
102
103export function pickFile() {
104 if (!global.isAndroid) {
105 return;
106 }
107 Application.android.on('activityResult', (args) => {
108 if (args.requestCode === 1000) {
109 const file = args.intent.getData().toString();
110 //const file = File.fromPath(args.intent.getData().toString());
111 //console.log(file);
112 //readFile(file);
113 //copyFile(file);
114 console.time('fromPath: copy');
115 const f = File.fromPath(file, true);
116 console.timeEnd('fromPath: copy');
117 console.log('old path: ', file);
118 console.log('new path: ', f.path, f.extension, f.size);
119 }
120 });
121 const Intent = android.content.Intent;
122 const picker = new Intent(Intent.ACTION_OPEN_DOCUMENT);
123 picker.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
124 picker.addCategory(Intent.CATEGORY_OPENABLE);
125 picker.setType('*/*');
126 Application.android.foregroundActivity.startActivityForResult(picker, 1000);
127}
128
129function readFile(selected: string) {
130 let applicationContext = Utils.android.getApplicationContext();

Callers

nothing calls this directly

Calls 6

timeMethod · 0.80
timeEndMethod · 0.80
onMethod · 0.65
toStringMethod · 0.45
fromPathMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected