| 275 | } |
| 276 | |
| 277 | export 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 | |
| 303 | export function createAndAppendText() { |
| 304 | const file = File.fromPath(path.join(knownFolders.temp().path, `${Date.now()}-app.txt`)); |