免费国产欧美国日产_少妇AV一区二区三区无码_蜜桃精品av无码喷奶水小说_jk18禁网站视频_精产国品一二三级产品区别_被夫の上司に犯波多野结衣_78m成人手机免费看_最爽最刺激18禁视频_偷偷色噜狠狠狠狠的777米奇

易優(yōu)GEO 重磅上線 ~ 一站式GEO優(yōu)化工具,讓豆包、文心一言、DeepSeek 在回答中主動推薦你的品牌,搶占AI流量入口!  點擊查看

小程序模板網(wǎng)

微信小程序1028版本新增:文件管理 API說明

發(fā)布時間:2017-11-20 17:06 所屬欄目:小程序開發(fā)文檔

wx.saveFile(OBJECT)保存文件到本地。OBJECT參數(shù)說明:參數(shù)類型必填說明tempFilePathString是需要保存的文件的臨時路徑successFunction否返回文件的保存路徑,res = {savedFilePath: '文件的保存路徑'}failFunction ...

 
 
 

wx.saveFile(OBJECT)

保存文件到本地。
OBJECT參數(shù)說明:
[tr]參數(shù)類型必填說明[/tr]

 

tempFilePath String 需要保存的文件的臨時路徑
success Function 返回文件的保存路徑,res = {savedFilePath: '文件的保存路徑'}
fail Function 接口調(diào)用失敗的回調(diào)函數(shù)
complete Function 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

示例代碼:

1
2
3
4
5
6
7
8
9
10
wx.startRecord({
    success: function(res) {
        var tempFilePath = res.tempFilePath wx.saveFile({
            tempFilePath: tempFilePath,
            success: function(res) {
                var savedFilePath = res.savedFilePath
            }
        })
    }
}) wx.getSavedFileList(OBJECT)

 



獲取本地已保存的文件列表
OBJECT參數(shù)說明:
[tr]參數(shù)類型必填說明[/tr]

success Function 接口調(diào)用成功的回調(diào)函數(shù),返回結(jié)果見success返回參數(shù)說明
fail Function 接口調(diào)用失敗的回調(diào)函數(shù)
complete Function 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

success返回參數(shù)說明:
[tr]參數(shù)類型說明[/tr]

errMsg String 接口調(diào)用結(jié)果
fileList Object Array 文件列表

fileList中的項目說明:
[tr]鍵類型說明[/tr]

filePath String 文件的本地路徑
createTime Number 文件的保存時的時間戳,從1970/01/01 08:00:00 到當前時間的秒數(shù)
size Number 文件大小,單位B

示例代碼:

1
2
3
4
5
wx.getSavedFileList({
    success: function(res) {
        console.log(res.fileList)
    }
}) wx.getSavedFileInfo(OBJECT)

 

復制代碼
獲取本地文件的文件信息
OBJECT參數(shù)說明:
[tr]參數(shù)類型必填說明[/tr]

filePath String 文件路徑
success Function 接口調(diào)用成功的回調(diào)函數(shù),返回結(jié)果見success返回參數(shù)說明
fail Function 接口調(diào)用失敗的回調(diào)函數(shù)
complete Function 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

success返回參數(shù)說明:
[tr]參數(shù)類型說明[/tr]

errMsg String 接口調(diào)用結(jié)果
size Number 文件大小,單位B
createTime Number 文件的保存是的時間戳,從1970/01/01 08:00:00 到當前時間的秒數(shù)

示例代碼:

1
2
3
4
5
6
7
wx.getSavedFileInfo({
    filePath: 'wxfile://somefile',
    //僅做示例用,非真正的文件路徑
    success: function(res) {
        console.log(res.size) console.log(res.createTime)
    }
}) wx.removeSavedFile(OBJECT)

 

 



刪除本地存儲的文件
OBJECT參數(shù)說明:
[tr]參數(shù)類型必填說明[/tr]

filePath String 需要刪除的文件路徑
success Function 接口調(diào)用成功的回調(diào)函數(shù)
fail Function 接口調(diào)用失敗的回調(diào)函數(shù)
complete Function 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

示例代碼:

1
2
3
4
5
6
7
8
9
10
11
12
wx.getSavedFileList({
    success: function(res) {
        if (res.fileList.length > 0) {
            wx.removeSavedFile({
                filePath: res.fileList[0].filePath,
                complete: function(res) {
                    console.log(res)
                }
            })
        }
    }
}) wx.openDocument(OBJECT)

 

 



新開頁面打開文檔,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx
OBJECT參數(shù)說明:
[tr]參數(shù)說明必填說明[/tr]

filePath String 文件路徑,可通過 downFile 獲得
success Function 接口調(diào)用成功的回調(diào)函數(shù)
fail Function 接口調(diào)用失敗的回調(diào)函數(shù)
complete Function 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

示例代碼

1
2
3
4
5
6
7
8
9
10
11
12
wx.downloadFile({
  url: 'http://example.com/somefile.pdf',
  success: function (res) {
    var filePath = res.tempFilePath
    wx.openDocument({
      filePath: filePath,
      success: function (res) {
        console.log('打開文檔成功')
      }
    })
  }
})


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.szcjxy.com/wxmini/doc/develop/17845.html 復制鏈接 如需定制請聯(lián)系易優(yōu)客服咨詢: 點擊咨詢
在線客服