Giter VIP home page Giter VIP logo

aliyunoos-wx-upload-file's Introduction

微信小程序上传图片到阿里云oss完整demo

需要配置阿里云 外网访问的Bucket 域名、以及阿里云AccessKey_ID、阿里云AccessKey_Secret 即可体验。

参照 https://www.jianshu.com/p/34d6dcbdc2e5 此篇博客基础上实现,添加了上传回调的设置。

配置文件 aliyun_oss/config.php 文件

配置文件中的 callbackBody 参数就是阿里云OSS返回给应用服务器的对应的具体信息

callbackBody中可以设置的系统变量有,其中imageInfo针对于图片格式,如果为非图片格式都为空:

系统变量 含义

bucket bucket

object object

etag 文件的etag,即返回给用户的etag字段

size object大小,CompleteMultipartUpload时为整个object的大小

mimeType 资源类型,如jpeg图片的资源类型为image/jpeg

imageInfo.height 图片高度

imageInfo.width 图片宽度

imageInfo.format 图片格式,如jpg、png等

注意:回调路由在正确回调之后返回值应为如下格式

<?php

    header("Content-Type: application/json");
    
    $data = array("Status"=>"Ok");
    
    echo json_encode($data);
?>

应用服务器回调具体可以参考https://help.aliyun.com/document_detail/31989.html?spm=a2c4g.11186623.2.13.73a83681rmUW8l#reference_b3p_cyw_wdb


服务端签名后直传案例 https://help.aliyun.com/document_detail/31926.html?spm=a2c4g.11186623.6.642.602872c1JV1kcV

Web端直传实践简介案例 https://help.aliyun.com/document_detail/31923.html?spm=a2c4g.11186623.6.640.1dcc4382zt0Wz7

JavaScript客户端签名直传案例 https://help.aliyun.com/document_detail/31925.html?spm=a2c4g.11186623.6.641.12c66212CeFVMm

aliyunoos-wx-upload-file's People

Contributors

jonexyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.