zoukankan      html  css  js  c++  java
  • js 上传文件到oss

    function upload_oss(file, all_file, accessKeyId, accessKeySecret, bucket, layer){
         // 创建客户端 var client = new OSS.Wrapper({ region: 'oss-cn-beijing',//你的oss地址 ,具体位置见下图 accessKeyId: accessKeyId,//你的ak accessKeySecret: accessKeySecret,//你的secret bucket: bucket//你的oss buct名字 }); console.log(all_file)
          // 开始上传, all_file 是在oss 的 路径 + 文件名 , file 是文件 client.multipartUpload( all_file, file).then(function (result) { console.log(result) layer.msg("上传成功", function(){ layer.closeAll(); window.location.reload(); }) }).catch(function (err) { console.log(err) layer.msg("上传失败", function(){ layer.closeAll(); }) }); };

      需要导入:

    <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.4.4.min.js"></script>
    //客户端一般不存储, oss 相关内容, 从后台获取
  • 相关阅读:
    01 网络基础
    01 ansible的基本介绍
    10 面向对象的编程
    03 docker容器镜像基础
    09 异常处理
    08 输入输出
    07 数据结构
    02 docker的基本用法
    01 docker容器技术基础入门
    06 字符串
  • 原文地址:https://www.cnblogs.com/ShanCe/p/14382776.html
Copyright © 2011-2022 走看看