Product Overview
Features and Strengths
Use Cases
System Limits
//Step 1: Introduce the Web SDK.import tcb from "@cloudbase/js-sdk";//Step 1: Perform initialization.const app = tcb.init({env: "your-env-id"});/**Step 3: Login authentication process. The code is omitted here. See:https://www.tencentcloud.com/document/product/876/41728?from_cn_redirect=1*/app.uploadFile({// Path of cloud storage.cloudPath: "dirname/filename",// File to be uploaded. File type.filePath: document.getElementById("file").files[0]}).then((res) => {// Return the file ID.console.log(res.fileID);});
//First, use wx.cloud.init for initialization. There is no need to import the SDK again on the mini program side, and authentication is not required.wx.cloud.uploadFile({cloudPath: "example.png", // Path of uploading files to the cloud.filePath: "" // Temporary file path for mini programs, which needs to be obtained by combining with APIs related to mini programs.}).then((res) => {// Return the file ID.console.log(res.fileID);});
const tcb = require("@cloudbase/node-sdk");const fs = require("fs");const app = tcb.init();app.uploadFile({cloudPath: "path/test.jpg",fileContent: fs.createReadStream("test.jpg")}).then((res) => {// Return the file ID.console.log(res.fileID);});
/.フィードバック