Loading…

Upload files (pictures/videos)

If possible, try to compress images and videos on the front end before uploading. This can reduce the capacity of images and videos, speed up loading, and reduce storage capacity: WeChat Mini Program pictures can be used [https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.compressImage.html](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.compressImage.html) WeChat Mini Program videos are available [https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.compressVideo.html](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.compressVideo.html) uni-app corresponds to `uni.compressImage` and `uni.compressVideo` H5 can use corresponding npm components, and other methods such as native apps can use corresponding solutions. # Upload local files ```javascript WXAPI.uploadFileV3({ token: '000' }) ``` + token login user token + tempFilePath is the temporary path of the local file. Please see the detailed description below for how to obtain it. + expireHours This parameter does not need to be passed. If it is passed, the file will be automatically deleted after the specified n hours. + faceDetect Whether to detect faces, if true, the face vector data will be returned ```json { "code": 0, "data": { "msg": "SUCCESS", "originalName": "KxwOAEbRr12j7f9cb25ea21c76ddf12d48994d78b1f3.jpeg", "size": "113718", "name": "cuser/951/2021/12/15/c365b6cb-f688-4298-8455-2e57a63d4bc5.jpeg", "id": "2281997", "type": ".jpeg", "url": "https://7.s2m.cc/cuser/951/2021/12/15/c365b6cb-f688-4298-8455-2e57a63d4bc5.jpeg" }, "msg": "success" } ``` + originalName original file name + size file capacity (Byte) + url image address + face_count How many faces have been detected in total + faces face detection results [returns the string of this array, you need to convert the string into an array object before use] - bbox face coordinates [1,2,3,4] - det_score detects the value of score 0~1 - embedding face vector data (512 latitudes) [..., ..., ...] ## WeChat Mini Program gets tempFilePath [https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html) ## Toutiao applet gets tempFilePath [https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/api/media/picture/tt-choose-image](https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/api/media/picture/tt-choose-image) ## uni-app gets tempFilePath [https://uniapp.dcloud.io/api/media/image?id=chooseimage](https://uniapp.dcloud.io/api/media/image?id=chooseimage) # Download the image address and upload it ```javascript WXAPI.uploadFileFromUrlV2({ remoteFileUrl: 'http://.............jpg', ext: '.jpg', expireHours: 1 }) ``` + remoteFileUrl remote access address of the image + ext file extension, such as: .jpg + expireHours is the number of hours after which the image will be automatically deleted. If this parameter is not passed, it will not be deleted. + faceDetect Whether to detect faces, if true, the face vector data will be returned ```json { "code": 0, "data": { "msg": "SUCCESS", "originalName": "KxwOAEbRr12j7f9cb25ea21c76ddf12d48994d78b1f3.jpeg", "size": "113718", "name": "cuser/951/2021/12/15/c365b6cb-f688-4298-8455-2e57a63d4bc5.jpeg", "id": "2281997", "type": ".jpeg", "url": "https://7.s2m.cc/cuser/951/2021/12/15/c365b6cb-f688-4298-8455-2e57a63d4bc5.jpeg" }, "msg": "success" } ``` + originalName original file name + size file capacity (Byte) + url image address + face_count How many faces have been detected in total + faces face detection results [returns the string of this array, you need to convert the string into an array object before use] - bbox face coordinates [1,2,3,4] - det_score detects the value of score 0~1 - embedding face vector data (512 latitudes) [..., ..., ...] # Get the uploaded file list ```javascript WXAPI.uploadFileListV2({ path: 'abc' }) ``` + Path is passed empty by default, and the files in the root directory will be obtained. If you want to obtain files in the specified directory, just pass the specific directory. # Pull the gallery image list ```javascript WXAPI.galleryList({ page: 1 }) ``` + page gets the page data. If this parameter is not passed, the default value is 1. + pageSize How many records are obtained per page? If this parameter is not passed, the default is 50 + categoryId gallery ID ```json { "code": 0, "data": { "result": [ { "dateAdd": "2022-10-26 21:48:58", "fileType": 0, "fileTypeStr": "picture", "originalName":"21.jpg", "protect": false, "size": 94334, "sizeStr": "92.12 KB", "suffix": ".jpg", "urlFull": "https://dcdn.it120.cc/2022/10/26/3391d55b-4e18-4233-a6e0-cdcd0be8eba5.jpg", "urlNoDomain": "2022/10/26/3391d55b-4e18-4233-a6e0-cdcd0be8eba5.jpg" } ], "totalPage": 1, "totalRow": 21 }, "msg": "success" } ```