-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added buttons to advance to the next shot and to download the current…
… shot.
- Loading branch information
1 parent
dcfdd6b
commit be932e3
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const downloadImage = (imageUrl) => { | ||
fetch(imageUrl) | ||
.then(response => response.blob()) | ||
.then(blob => { | ||
// Create a temporary anchor element | ||
const url = window.URL.createObjectURL(blob); | ||
const link = document.createElement('a'); | ||
link.href = url; | ||
|
||
// Extract the filename from the URL | ||
const filename = imageUrl.substring(imageUrl.lastIndexOf('/') + 1); | ||
|
||
// Set the download attribute and filename | ||
link.setAttribute('download', filename); | ||
document.body.appendChild(link); | ||
|
||
// Simulate a click on the anchor element to start the download | ||
link.click(); | ||
|
||
// Clean up the temporary anchor element | ||
link.parentNode.removeChild(link); | ||
}) | ||
.catch(error => { | ||
console.error('Error downloading image:', error); | ||
}); | ||
}; |