Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nodenogg-duplicate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adam Procter
nodenogg-duplicate
Commits
c762a013
Commit
c762a013
authored
4 years ago
by
Adam Procter
Browse files
Options
Downloads
Patches
Plain Diff
ipfs working
create node, hash image and display working
parent
efcccfcf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/components/IpfsInfo.vue
+49
-17
49 additions, 17 deletions
app/src/components/IpfsInfo.vue
with
49 additions
and
17 deletions
app/src/components/IpfsInfo.vue
+
49
−
17
View file @
c762a013
...
...
@@ -3,9 +3,15 @@
<h1>
IPFS View
</h1>
<h3>
Testing Only
</h3>
<h1>
{{
status
}}
</h1>
<h2>
ID:
{{
id
}}
</h2>
<h2>
Agent version:
{{
agentVersion
}}
</h2>
<h3>
Files :
{{
fileContents
}}
</h3>
<!--
<h2>
ID:
{{
id
}}
</h2>
-->
<!--
<h2>
Agent version:
{{
agentVersion
}}
</h2>
-->
<!--
<h3>
Files :
{{
fileContents
}}
</h3>
-->
<!--
<h3>
Path:
{{
path
}}
</h3>
-->
<div
v-if=
"path == 'ready'"
></div>
<div
v-else
>
<img
:src=
"'https://ipfs.io/ipfs/' + path"
/>
</div>
<!--
<img
:src=
"'data:image/jpg;base64,' + output"
/>
-->
<form>
<input
...
...
@@ -28,8 +34,9 @@
import
VueIpfs
from
'
ipfs
'
const
ipfs
=
VueIpfs
.
create
()
var
node
var
file
const
fileContents
=
[]
var
output
var
path
=
'
ready
'
//const fileContents = []
// The below code should create an IPFS node to add files to
export
default
{
...
...
@@ -37,10 +44,12 @@ export default {
data
:
function
()
{
return
{
status
:
'
Connecting to IPFS...
'
,
id
:
''
,
agentVersion
:
''
,
//
id: '',
//
agentVersion: '',
selectedFile
:
null
,
fileContents
:
this
.
fileContents
,
output
:
output
,
path
:
path
,
}
},
mounted
:
function
()
{
...
...
@@ -52,11 +61,16 @@ export default {
this
.
selectedFile
=
event
.
target
.
files
[
0
]
},
saveIPFS
()
{
file
=
node
.
files
.
write
(
'
/
'
+
this
.
selectedFile
.
name
,
this
.
selectedFile
,
{
create
:
true
,
})
return
file
async
saveIPFS
()
{
// file = node.files.write('/' + this.selectedFile.name, this.selectedFile, {
// create: true,
// })
// return file
for
await
(
const
result
of
node
.
add
(
this
.
selectedFile
))
{
//console.log(result.cid.string)
this
.
fileContents
=
result
// console.log(this.fileContents.path)
}
},
// getIPFS() {
...
...
@@ -66,11 +80,25 @@ export default {
// return fileContents
// },
getIPFS
()
{
const
resultPart
=
node
.
files
.
read
(
'
/
'
)
fileContents
.
push
(
resultPart
)
// console.log(fileContents)
return
fileContents
async
getIPFS
()
{
// const resultPart = node.files.read('/')
// fileContents.push(resultPart)
// // console.log(fileContents)
// return fileContents
for
await
(
const
newfile
of
node
.
get
(
this
.
fileContents
.
path
))
{
console
.
log
(
newfile
.
path
)
this
.
path
=
newfile
.
path
}
// const chunks = []
// for await (const chunk of node.cat(file)) {
// chunks.push(chunk)
// }
// output = Buffer.concat(chunks).toString('base64')
// //output = this.fileContents.path
// file = this.fileContents.path
// console.log(Buffer.concat(chunks).toString('base64'))
},
async
getIpfsNodeInfo
()
{
...
...
@@ -105,6 +133,10 @@ export default {
margin-right
:
1em
;
}
img
{
width
:
50%
;
}
h1
{
font-size
:
1em
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment