leancloud上传图片js_leanCloud上传多个图片保存到一个数组中的疑惑

我的需求是,上传多个图片,然后图片保存到数组中,再把数组保存到对象中,最后再上传到云端。

我的意思就是一个数组中包含多个图片,然后数组保存在对象中。

下图为web界面

var Product = AV.Object.extend('Product');

function releaseNewProduct() {

var title = $('#inputTitle').val();

var price = parseFloat($('#inputPrice').val());

var description = $('#inputDescription').val();

var currentUser = AV.User.current();

const avFiles = [];

var files = $('#inputFile1 input');

for ( let i = 0; i < files.length; i++) {

let name = files[i].files[0].name;

let avFile = new AV.File( name, files[i].files[0]);

avFiles.push(avFile)

}

// LeanCloud - 对象

var product = new Product();

product.set('title', title);

product.set('price', price);

product.set('description', description);

product.set('owner', AV.User.current());

product.addUnique('image', avFiles);

product.save().then(function() {

window.location.href = "./../products-list/products-list.html";

}, function(error) {

alert(JSON.stringify(error));

});

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Flutter Web 3.0 中使用 LeanCloud 实现用户登录,可以通过 LeanCloud 的 _User 类来实现。下面是一个简单的示例: 1. 首先,在 LeanCloud 控制台中创建一个应用并获取应用的 App ID 和 App Key。 2. 在 Flutter 项目中引入 LeanCloud SDK,可以在 pubspec.yaml 文件中添加依赖: ``` dependencies: leancloud_storage: ^1.0.9 ``` 3. 在应用启动时初始化 LeanCloud SDK: ```dart import 'package:leancloud_storage/leancloud.dart'; void main() async { await LeanCloud.initialize('yourAppId', 'yourAppKey'); runApp(MyApp()); } ``` 4. 创建一个登录页面,在页面中添加用户名和密码的输入框以及登录按钮。当用户点击登录按钮时,调用以下代码来完成登录: ```dart import 'package:leancloud_storage/leancloud.dart'; Future<void> login(String username, String password) async { try { await LeanCloudUser.login(username, password); print('登录成功'); } on LCException catch (e) { print('登录失败,错误码:${e.code},错误信息:${e.message}'); } } ``` 如果登录成功,用户对象会被缓存在本地,可以通过以下方法获取当前已登录的用户: ```dart import 'package:leancloud_storage/leancloud.dart'; LCUser? currentUser = await LCUser.getCurrent(); ``` 如果用户已登录,可以调用以下代码注销当前用户: ```dart import 'package:leancloud_storage/leancloud.dart'; await LCUser.logout(); ``` 注意:为了护用户的隐私,建议使用 HTTPS 协议来证数据传输的安全。如果使用 HTTP 协议,需要在初始化 LeanCloud SDK 时设置 enableInsecureProtocol 为 true: ```dart await LeanCloud.initialize('yourAppId', 'yourAppKey', enableInsecureProtocol: true); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值