$("#btnSubmit").click(function (event) { var file = $("#ipfile")[0].files[0]; var contentType=!!file.type?file.type:"video/x-flv";
//请求api接口:调用amzon s3/minio的sdk获取临时上传预签名url var url =`http://apiUrl?fileName=${file.name}&expires=20&contentType=${contentType}`; //使用httpGet获取预签名url $.getJSON(url, function (data) {
//请求临时预签名url使用httpPut上传文件 $.ajax({ url: data['Data'],//data['Data']为获取的预签名URL type: 'PUT', data: file, processData: false, contentType: contentType, success: function (json) { console.log('Upload complete!') }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log('Upload error: ' + XMLHttpRequest .responseText); } }); }); }); });
标签:function,contentType,url,签名,file,上传 From: https://www.cnblogs.com/zmxmiss/p/13452875.html