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

How to use pre-existing space for uploading files on web3.storage #1443

Open
Mihir02 opened this issue May 9, 2024 · 1 comment
Open

How to use pre-existing space for uploading files on web3.storage #1443

Mihir02 opened this issue May 9, 2024 · 1 comment

Comments

@Mihir02
Copy link

Mihir02 commented May 9, 2024

`import { create } from '@web3-storage/w3up-client'

export const IPFS_GATEWAY = "https://ipfs.io/ipfs/";

export const ipfsSaveContent = async (files) => {
const client = await create()

// get an email to use for the w3up account that will control the space
const inputEmail = process.env.Email

// account associated with input email
let myAccount
if (inputEmail) {
console.warn(`about to w3up client.login with email ${inputEmail}`)
myAccount = await client.login(inputEmail)
}

const sharkDaoSpace = await client.createSpace('sharkDAO.xyz')

// console.log('sharkDaoSpace', sharkDaoSpace)

if (myAccount) {
console.warn(`account ${myAccount.did()} is adding a provider to space ${sharkDaoSpace.did()}`)
await myAccount.provision(sharkDaoSpace.did())
}

// this is what was missing but I didn't know it at the time
await client.addSpace(await sharkDaoSpace.createAuthorization(client))
await client.setCurrentSpace(sharkDaoSpace.did())
const sharkPics = await client.uploadDirectory([files])

await sharkDaoSpace.save()
console.log(sharkPics.toString())

return sharkPics.toString();

};
`

I want to use a pre-existing space that I created manually on web3.storage console. For now, this is the only way I know to upload files successfully on different spaces apparently linked to my account, which is not showing up on my console.
web3

@aarontravass
Copy link

If I understand your question correctly, you want to use a space that was created via your console. Maybe try using account.provision? Copy the space did from your console and do await account.provision(spaceDid). spaceDid is a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants