上传文件到云存储:async function uploadFileToCloud(filePath, cloudFileName) { const fileStream = await file.open(filePath); const buffer = new ArrayBuffer(1024); let bytesRead = await file.read(fileStream.fd, buffer, 0, buffer.byteLength); const uploadTask = cloud.upload(cloudFileName); while (bytesRead > 0) { await uploadTask.write(buffer.slice(0, bytesRead)); bytesRead = await file.read(fileStream.fd, buffer, 0, buffer.byteLength); } await uploadTask.close(); await file.close(fileStream.fd); }
上传文件到云存储: