-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3
- Loading branch information
Showing
3 changed files
with
25 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import { FleekSdk, ApplicationAccessTokenService } from '@fleekxyz/sdk'; | ||
|
||
let fleekSdk!:FleekSdk; | ||
let fleekSdk!: FleekSdk; | ||
|
||
const initialize = Object.freeze((clientId: string) => { | ||
const applicationService = new ApplicationAccessTokenService({ | ||
clientId, | ||
}); | ||
fleekSdk = new FleekSdk({ accessTokenService: applicationService }); | ||
const applicationService = new ApplicationAccessTokenService({ | ||
clientId | ||
}); | ||
fleekSdk = new FleekSdk({ accessTokenService: applicationService }); | ||
}); | ||
|
||
const uploadToIPFS = Object.freeze(async (filename: string, content: Buffer) => { | ||
if (!fleekSdk) { | ||
throw new Error('Fleek SDK not initialized'); | ||
} | ||
const result = await fleekSdk.ipfs().add({ | ||
path: filename, | ||
content: content, | ||
}) | ||
|
||
return result | ||
}); | ||
const uploadToIPFS = Object.freeze( | ||
async (filename: string, content: Buffer) => { | ||
if (!fleekSdk) { | ||
throw new Error('Fleek SDK not initialized'); | ||
} | ||
const result = await fleekSdk.ipfs().add({ | ||
path: filename, | ||
content: content | ||
}); | ||
|
||
return result; | ||
} | ||
); | ||
|
||
const FleekStorageProvider = { | ||
initialize, | ||
uploadToIPFS, | ||
} | ||
initialize, | ||
uploadToIPFS | ||
}; | ||
|
||
export default FleekStorageProvider; | ||
export default FleekStorageProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters