This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 1 file changed +24
-1
lines changed
examples/transfer-files/complete/js 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ const $allDisabledInputs = document.querySelectorAll('input:disabled')
20
20
let ipfs
21
21
let peerInfo
22
22
23
+ // TODO groups
24
+ // ipfs stuff
25
+ // creating html stuff
26
+ // event listeners
27
+ // states
28
+
23
29
function start ( ) {
24
30
if ( ! ipfs ) {
25
31
updateView ( 'starting' , ipfs )
@@ -74,6 +80,19 @@ const catFile = () => {
74
80
console . log ( 'file got end' )
75
81
console . log ( buf )
76
82
} )
83
+ // TODO currently, can't grab content from file either in get...
84
+ const downloadContent = window . btoa ( window . unescape ( window . encodeURIComponent ( 'content of file' ) ) )
85
+ const downloadLink = 'data:application/octet-stream;charset=utf-8;base64,' + downloadContent
86
+ const listItem = document . createElement ( 'div' )
87
+ const link = document . createElement ( 'a' )
88
+ link . setAttribute ( 'href' , downloadLink )
89
+ link . setAttribute ( 'download' , multihash )
90
+ const date = ( new Date ( ) ) . toLocaleTimeString ( )
91
+ link . innerText = date + ' - ' + multihash + ' - Size: ' + file . size
92
+ const fileList = document . querySelector ( '.file-list' )
93
+
94
+ listItem . appendChild ( link )
95
+ fileList . insertBefore ( listItem , fileList . firstChild )
77
96
}
78
97
} )
79
98
stream . on ( 'end' , ( ) => {
@@ -208,4 +227,8 @@ function updateView (state, ipfs) {
208
227
}
209
228
}
210
229
211
- setupEventListeners ( )
230
+ const startApplication = ( ) => {
231
+ setupEventListeners ( )
232
+ }
233
+
234
+ startApplication ( )
You can’t perform that action at this time.
0 commit comments