| 248 | } |
| 249 | |
| 250 | export 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 | |
| 277 | export function createFileInMusic() { |
| 278 | if (!global.isAndroid) { |