Skip to content

Commit

Permalink
feat: include filename when sharing single file
Browse files Browse the repository at this point in the history
Closes #1346
  • Loading branch information
lidel committed Dec 3, 2019
1 parent e3cb6d8 commit bc57808
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ export async function getDownloadLink (files, gatewayUrl, apiUrl, ipfs) {

export async function getShareableLink (files, ipfs) {
let hash
let filename

if (files.length === 1) {
hash = files[0].hash
if (files[0].type === 'file') {
filename = `?filename=${encodeURIComponent(files[0].name)}`
}
} else {
hash = await makeHashFromFiles(files, ipfs)
}

return `https://ipfs.io/ipfs/${hash}`
return `https://ipfs.io/ipfs/${hash}${filename || ''}`
}

0 comments on commit bc57808

Please sign in to comment.