Skip to content

Commit

Permalink
feat: (sample) Add CSV and MOV file downloads (#171)
Browse files Browse the repository at this point in the history
Also changed the downloads to point directly to HTTPS urls because the local file downloads don't work for iOS
  • Loading branch information
corycaywood authored Nov 5, 2021
1 parent 7d1c415 commit 58a9bc9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Binary file removed js-miniapp-sample/src/assets/sample.mp3
Binary file not shown.
Binary file removed js-miniapp-sample/src/assets/sample.zip
Binary file not shown.
48 changes: 45 additions & 3 deletions js-miniapp-sample/src/pages/file-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ const FileDownload = (props: FileDownloadProps) => {
color="primary"
onClick={() =>
// $FlowFixMe
onDownloadFile(require('../assets/images/panda.png'), 'panda.png')
onDownloadFile(
'https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_100kB.jpg',
'sample.jpg'
)
}
>
Download Image
Expand All @@ -145,7 +148,10 @@ const FileDownload = (props: FileDownloadProps) => {
color="primary"
onClick={() =>
// $FlowFixMe
onDownloadFile(require('../assets/sample.zip'), 'sample.zip')
onDownloadFile(
'https://file-examples-com.github.io/uploads/2017/02/zip_2MB.zip',
'sample.zip'
)
}
>
Download ZIP
Expand All @@ -158,12 +164,48 @@ const FileDownload = (props: FileDownloadProps) => {
color="primary"
onClick={() =>
// $FlowFixMe
onDownloadFile(require('../assets/sample.mp3'), 'sample.mp3')
onDownloadFile(
'https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3',
'sample.mp3'
)
}
>
Download MP3
</Button>
</CardActions>

<CardActions className={classes.actions}>
<Button
variant="contained"
color="primary"
onClick={() =>
// $FlowFixMe
onDownloadFile(
'https://file-examples-com.github.io/uploads/2017/02/file_example_CSV_5000.csv',
'sample.csv'
)
}
>
Download CSV
</Button>
</CardActions>

<CardActions className={classes.actions}>
<Button
variant="contained"
color="primary"
onClick={() =>
// $FlowFixMe
onDownloadFile(
'https://file-examples-com.github.io/uploads/2018/04/file_example_MOV_480_700kB.mov',
'sample.mov'
)
}
>
Download MOV
</Button>
</CardActions>

<div className={classes.info}>
<p>
{!isPermissionGranted && '"FILE_DOWNLOAD" permission not granted.'}
Expand Down

0 comments on commit 58a9bc9

Please sign in to comment.