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

Function createFileInMusic

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

Source from the content-addressed store, hash-verified

275}
276
277export function createFileInMusic() {
278 if (!global.isAndroid) {
279 return;
280 }
281
282 Http.getFile('https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp3').then((result: File) => {
283 let file = File.android.createFile({
284 directory: AndroidDirectory.MUSIC,
285 name: `${Date.now()}.MP3`,
286 mime: 'audio/mp3',
287 relativePath: `NativeScript/MP3`,
288 });
289
290 result
291 .copy(file.path)
292 .then((done) => {
293 console.log('done: ' + done + '\n' + 'Original path: ' + result + '\n' + 'Copied to: ' + file.path + '\n' + 'Original size: ' + result.size + '\n' + 'Copy size: ' + file.size + '\n');
294
295 alert(`File saved in ${AndroidDirectory.MUSIC}/NativeScript/MP3`);
296 })
297 .catch((error) => {
298 console.error(error);
299 });
300 });
301}
302
303export function createAndAppendText() {
304 const file = File.fromPath(path.join(knownFolders.temp().path, `${Date.now()}-app.txt`));

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