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

Function createFileInGallery

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

Source from the content-addressed store, hash-verified

248}
249
250export function createFileInGallery() {
251 if (!global.isAndroid) {
252 return;
253 }
254 const width = Screen.mainScreen.widthPixels;
255 const height = Screen.mainScreen.heightPixels;
256 const randomImageUrl = `https://picsum.photos/${width}/${height}.jpg?random=${Date.now()}`;
257
258 Http.getFile(randomImageUrl).then((result: File) => {
259 let file = File.android.createFile({
260 directory: AndroidDirectory.PICTURES,
261 name: `${Date.now()}.jpg`,
262 mime: 'image/jpeg',
263 relativePath: `NativeScript`,
264 });
265 result
266 .copy(file.path)
267 .then((done) => {
268 console.log('done: ' + done + '\n' + 'Original path: ' + result + '\n' + 'Copied to: ' + file.path + '\n' + 'Original size: ' + result.size + '\n' + 'Copy size: ' + file.size + '\n');
269 alert(`File saved in ${AndroidDirectory.PICTURES}/NativeScript`);
270 })
271 .catch((error) => {
272 console.error(error);
273 });
274 });
275}
276
277export function createFileInMusic() {
278 if (!global.isAndroid) {

Callers

nothing calls this directly

Calls 6

alertFunction · 0.90
createFileMethod · 0.80
errorMethod · 0.80
getFileMethod · 0.65
copyMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected