Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add save to ipfs function #310

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add ipfs func
  • Loading branch information
suxinmin committed Aug 16, 2022
commit e7f70d864b4b762115a9cd62960048f36162e439
14 changes: 12 additions & 2 deletions src/functions.js
Original file line number Diff line number Diff line change
@@ -1114,8 +1114,18 @@ function file_save_as_to_ipfs(maybe_saved_callback = () => { }, update_from_save
}

function upload_to_ipfs(blob) {
const file = new File([blob], "file.png", { type: "image/png" });
const imghash = await ipfs.add(file);
const IPFS = require('ipfs-core');
const node = await IPFS.create()
const version = await node.version()

console.log('Version:', version.version)

const file = await node.add({
path: 'file.png',
content: blob
})

console.log('Added file:', file.path, file.cid.toString())
}

function are_you_sure(action, canceled, from_session_load) {