m***@163.com
m***@163.com
  • 发布:2024-03-24 00:25
  • 更新:2024-03-24 07:47
  • 阅读:117

求助 :需要uniapp x 上传文件的示例

分类:uts

插件市场有一个sn-uts-file插件能拿到文件路径,如/storage/emulated/0/Android/data/io.xxgsyth/apps/UNIxxxxxx/www/_doc/sp_20240323115132418.xlsx,接下来怎么处理才能读取到file对象啊?使用 const fileManager = uni.getFileSystemManager() ;fileManager.getFileInfo({}) 函数直接报错

const fileManager = uni.getFileSystemManager()  

fileManager.getFileInfo({  
                            filePath: this.filePath as string,  
                            digestAlgorithm: 'md5',  
                            success: function (res : GetFileInfoSuccessResult) {  
                                console.log('success')  
                                this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'  
                                console.log('success', res)  
                                this.getFileInfoSize = res.size  
                                this.getFileInfoDigest = res.digest  
                            },  
                            fail: function (res : UniError) {  
                                console.log('fail')  
                                this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'  
                                console.log('fail', res)  
                            },  
                            complete: function (res : any) {  
                                console.log("complete", res)  
                                // this.done = true  
                                // if (res instanceof UniError) {  
                                //  this.lastCompleteError = res  
                                // }  
                            }  
                        } as GetFileInfoOptions)  

# 报错信息  
{cause: {cause: null,   
    message: "Didn't find class io.dcloud.uniapp.extapi.UniFileSystemManagerKt" on path: DexPathList[  
            [dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/index/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/ucenter/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/login/account/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/xxgs/sales/daily/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/xxgs/sales/detail/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/xxgs/todo/index/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/pages/xxgs/transaction/dynamicMoney/index/classes.dex",  
             dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/uni_modules/kux-request/utssdk/app-android/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/uni_modules/kux-router/utssdk/app-android/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/uni_modules/x-grid-item/components/x-grid-item/x-grid-item/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/uni_modules/x-grid/components/x-grid/x-grid/classes.dex",   
            dex file "/storage/emulated/0/Android/data/io.xxgsyth/apps/__UNI__7FF2802/www/uni_modules/x-icon/components/x-icon/x-icon/classes.dex",   
            zip file "/data/app/~~djm4A50f4kTM_lbKCeAoQw==/io.xxgsyth-2iDWvzsiVYzTu3Oa55j2WQ==/base.apk"  
            ],nativeLibraryDirectories=[/data/app/~~djm4A50f4kTM_lbKCeAoQw==/io.xxgsyth-2iDWvzsiVYzTu3Oa55j2WQ==/lib/arm64, /data/app/~~djm4A50f4kTM_lbKCeAoQw==/io.xxgsyth-2iDWvzsiVYzTu3Oa55j2WQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64  
            ]  
        ]"  
    },   

  message: "Failed resolution of: Lio/dcloud/uniapp/extapi/UniFileSystemManagerKt;"  
}
2024-03-24 00:25 负责人:无 分享
已邀请:
码农朱哲

码农朱哲 - 一个10年+工作经验的全栈码农

想的复杂了哈,x有文件上传api的

https://doc.dcloud.net.cn/uni-app-x/api/upload-file.html

  • m***@163.com (作者)

    感谢大佬,哭死

    2024-03-24 08:36

要回复问题请先登录注册