Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bc3c29d
feat: add dropdown menu for import car
badgooooor Feb 1, 2025
d97c867
feat: add modal for import car
badgooooor Feb 1, 2025
a3d7418
locale: add en locale
badgooooor Feb 1, 2025
9488c3d
refactor,feat: change to functional component, add check file, rename…
badgooooor Feb 1, 2025
f0b44df
feat: wiring handling uploading car dag file
badgooooor Feb 1, 2025
742de35
locale: add placeholder
badgooooor Feb 3, 2025
e381d4e
feat: add import car file
badgooooor Feb 3, 2025
40f58d0
refactor: clear unused params
badgooooor Feb 3, 2025
5e324f3
update dependency
badgooooor Feb 4, 2025
ce09977
refactor: cleanup modal
badgooooor Feb 4, 2025
e7001ec
feat: update types
badgooooor Feb 4, 2025
f1abecf
feat: wip on dag import
badgooooor Feb 4, 2025
1eb486f
feat: add util
badgooooor Feb 6, 2025
0e6bdd4
feat: fix parse file for dag import
badgooooor Feb 6, 2025
f2271cc
docs: Add AddByCarModal as storybook
badgooooor Feb 6, 2025
d234a60
fix: fix typecheck error
badgooooor Feb 6, 2025
ab8b11f
fix: revert back
badgooooor Feb 7, 2025
3820dad
feat: update types of IPFSService
badgooooor Feb 10, 2025
e5b82d2
feat: revert types to use modified type
badgooooor Feb 10, 2025
fb82d3c
refactor: remove unused
badgooooor Feb 10, 2025
0576322
refactor: move definition from imports to local
badgooooor Feb 11, 2025
20c87e9
Merge branch 'main' into feat/import-dag-car-file
badgooooor Feb 22, 2025
23ab754
refactor: change to pass stream to dag import
badgooooor Feb 24, 2025
fb0f1c2
refactor: remove unused util
badgooooor Feb 24, 2025
2b16988
typo: Update wording
badgooooor Feb 27, 2025
9277e50
typo: Update wording in select file button
badgooooor Feb 27, 2025
979eba8
type: Update i18n, use wording for title in i18n
badgooooor Feb 27, 2025
f886da9
fix: fix logic on file name
badgooooor Feb 27, 2025
0ea5a82
fix: fix import to relative path within mfs
badgooooor Feb 27, 2025
8263556
Merge branch 'main' into feat/import-dag-car-file
badgooooor Feb 28, 2025
9ef6095
fix: icon, label, and styling
lidel Mar 4, 2025
b23ef89
docs: cli tutor for cat import
lidel Mar 4, 2025
a229aa9
chore: throw helpful error if name exists
2color Mar 5, 2025
5b35fec
fix: dont throw error when importing car if destination doesnt exist
SgtPooki Mar 5, 2025
a3abcce
fix: swallow error when file doesn't exist
2color Mar 5, 2025
bda1817
chore: remove unnecessary changes
SgtPooki Mar 5, 2025
838aae0
chore: use kubo-rpc-client types for IPFSService
SgtPooki Mar 5, 2025
d1ae76f
chore: minor ux fixes
SgtPooki Mar 5, 2025
2b929fc
fix: dont error if path doesn't exist
SgtPooki Mar 5, 2025
34f15dc
Merge branch 'main' into feat/import-dag-car-file
badgooooor Mar 5, 2025
8c5ff77
fix: remove duplicate catch block
SgtPooki Mar 5, 2025
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
feat: add util
  • Loading branch information
badgooooor committed Feb 6, 2025
commit 1eb486fb2c0b7379be28693964d158a1bb7f6e5e
20 changes: 20 additions & 0 deletions src/bundles/files/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Task from '../task.js'
/**
* @typedef {import('ipfs').IPFSService} IPFSService
* @typedef {import('kubo-rpc-client').KuboRPCClient} KuboRPCClient
* @typedef {import('../../lib/files').FileStream} FileStream
* @typedef {import('./actions').Ext} Ext
* @typedef {import('./actions').Extra} Extra
*/
Expand Down Expand Up @@ -316,3 +317,22 @@ export const ensureMFS = (store) => {
throw new Error('Unable to perform task if not in MFS')
}
}

/**
* Get bytes from file
* @param {FileStream} file
* @returns {Promise<Uint8Array<ArrayBuffer>>}
*/
export const fileToByteArray = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onloadend = () => {
const arrayBuffer = reader.result
if (arrayBuffer === null) resolve(new Uint8Array([]))
const byteArray = new Uint8Array(arrayBuffer)
resolve(byteArray)
}
reader.onerror = (error) => reject(error)
reader.readAsArrayBuffer(file.content)
})
}