[fix] mobile save syste
This commit is contained in:
@@ -102,6 +102,9 @@ export async function getFileSrc(loc:string) {
|
|||||||
}
|
}
|
||||||
return convertFileSrc(loc)
|
return convertFileSrc(loc)
|
||||||
}
|
}
|
||||||
|
if(forageStorage.isAccount && loc.startsWith('assets')){
|
||||||
|
return hubURL + `/rs/` + loc
|
||||||
|
}
|
||||||
if(Capacitor.isNativePlatform()){
|
if(Capacitor.isNativePlatform()){
|
||||||
if(!await checkCapFileExists({
|
if(!await checkCapFileExists({
|
||||||
path: loc,
|
path: loc,
|
||||||
@@ -116,9 +119,6 @@ export async function getFileSrc(loc:string) {
|
|||||||
return Capacitor.convertFileSrc(uri.uri)
|
return Capacitor.convertFileSrc(uri.uri)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(forageStorage.isAccount && loc.startsWith('assets')){
|
|
||||||
return hubURL + `/rs/` + loc
|
|
||||||
}
|
|
||||||
if(usingSw){
|
if(usingSw){
|
||||||
const encoded = Buffer.from(loc,'utf-8').toString('hex')
|
const encoded = Buffer.from(loc,'utf-8').toString('hex')
|
||||||
let ind = fileCache.origin.indexOf(loc)
|
let ind = fileCache.origin.indexOf(loc)
|
||||||
@@ -220,16 +220,6 @@ export async function saveAsset(data:Uint8Array, customId:string = '', fileName:
|
|||||||
await writeBinaryFile(`assets/${id}.${fileExtension}`, data ,{dir: BaseDirectory.AppData})
|
await writeBinaryFile(`assets/${id}.${fileExtension}`, data ,{dir: BaseDirectory.AppData})
|
||||||
return `assets/${id}.${fileExtension}`
|
return `assets/${id}.${fileExtension}`
|
||||||
}
|
}
|
||||||
else if(Capacitor.isNativePlatform()){
|
|
||||||
const path = `assets/${id}.${fileExtension}`
|
|
||||||
await CapFS.Filesystem.writeFile({
|
|
||||||
path: path,
|
|
||||||
data: Buffer.from(data).toString('base64'),
|
|
||||||
directory: CapFS.Directory.External,
|
|
||||||
recursive: true,
|
|
||||||
})
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
else{
|
else{
|
||||||
let form = `assets/${id}.${fileExtension}`
|
let form = `assets/${id}.${fileExtension}`
|
||||||
const replacer = await forageStorage.setItem(form, data)
|
const replacer = await forageStorage.setItem(form, data)
|
||||||
|
|||||||
Reference in New Issue
Block a user