From 8cd4361c8e15d1f4c34a080614043223810300d0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 3 Dec 2019 22:30:37 +0100 Subject: [PATCH] feat: include filename when sharing single file Closes #1346 --- src/lib/files.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/files.js b/src/lib/files.js index 4843c6f62..05e85ccda 100644 --- a/src/lib/files.js +++ b/src/lib/files.js @@ -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 || ''}` }