Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: web3-storage/web3.storage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: IndyVerse/web3.storage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 23, 2022

  1. need to define process

    gyuri-lajos committed Jan 23, 2022
    Copy the full SHA
    aa01831 View commit details
  2. Copy the full SHA
    1bcf1a5 View commit details
5 changes: 5 additions & 0 deletions packages/client/examples/browser/next.js/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useState, useReducer } from 'react'
import { Web3Storage } from 'web3.storage'

const process = {
browser: true,
env: {
}
};
export default function Home () {
const [messages, showMessage] = useReducer((msgs, m) => msgs.concat(m), [])
const [token, setToken] = useState('')
7 changes: 7 additions & 0 deletions packages/client/examples/browser/webpack5/index.html
Original file line number Diff line number Diff line change
@@ -76,6 +76,13 @@ <h1>⁂
<input type="submit" value="Submit" id="submit" />
</form>
<div id="output"></div>
<script>
process = {
browser: true,
env: {
}
};
</script>
<script src="/main.bundle.js"></script>
</body>
</html>
13 changes: 10 additions & 3 deletions packages/client/examples/browser/webpack5/main.js
Original file line number Diff line number Diff line change
@@ -7,13 +7,20 @@ const output = document.querySelector('#output')

showMessage('> ⁂ waiting for form submission...')

showMessage('> 📦 creating web3.storage client')
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDg1ODBBQTYyMDczZUJERjI4RTY3ODQxRDg5YzM4M0NkRWFmNWIwY0UiLCJpc3MiOiJ3ZWIzLXN0b3JhZ2UiLCJpYXQiOjE2NDIxNzE0MTA0ODMsIm5hbWUiOiJJbmR5VmVyc2UvV2ViMy5zdG9yYWdlIGxvY2FsIn0.lcaTOY5hgrps_sf-RJjO8spN30TICHw5mZ4m2810Xyk'
const client = new Web3Storage({ token })
showMessage('> 📦 access web3.storage client as window.web3')
window.web3 = client
parent.wweb3p = client
console.log(window.web3)
form.addEventListener('submit', async function (event) {
// don't reload the page!
event.preventDefault()

showMessage('> 📦 creating web3.storage client')
const token = tokenInput.value
const client = new Web3Storage({ token })
const client = window.web3

showMessage('> 🤖 chunking and hashing the files (in your browser!) to calculate the Content ID')
const files = filepicker.files
@@ -36,13 +43,13 @@ form.addEventListener('submit', async function (event) {
showMessage(`> ⁂ ${totalBytes.toLocaleString()} bytes stored!`)
}, false)

function showMessage (text) {
function showMessage(text) {
const node = document.createElement('div')
node.innerText = text
output.appendChild(node)
}

function showLink (url) {
function showLink(url) {
const node = document.createElement('a')
node.href = url
node.innerText = `> 🔗 ${url}`