gpt4 book ai didi

jquery - Plupload 亚马逊 S3 缓存控制

转载 作者:行者123 更新时间:2023-12-01 01:48:17 25 4
gpt4 key购买 nike

我们正在使用 PLupload 将图像上传到亚马逊 S3 存储桶。但我们需要对上传的文件设置cache-control。

我尝试添加 header {'cache-control':'155520000'},并将其添加到 multipart_params 下。运气不好。

以下是我们使用的代码。任何帮助将不胜感激。

$(function() {
$('#progressbar').hide();
var uploader = new plupload.Uploader({
init : {
FilesAdded: function(up, files) {
plupload.each(files, function(file) {
if (up.files.length > 1) {
up.removeFile(file);
}
});
},
},
preinit : {

UploadFile: function(up, file) {
var filenamevous;
if('thumb' in file){
up.settings.multipart_params.key = 'thumb_'+imagename;
}
else
{
up.settings.multipart_params.key = makeid()+'.jpg';
}

imagename = up.settings.multipart_params.key;
var filenamevous;
filenamevous = $("#txtImageTitle").val();

var category;
category = $("#category").val();
$.post("<?php echo $this->config->item('actionFeUrl'); ?>/pictures/ajax",{imname:imagename,oriname:filenamevous,catName:category,task:'uploadedimage'},function(data)
{

});
}
},

runtimes : 'flash,silverlight,html5',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
multi_selection: false,
multipart: true,
multipart_params: {
'key': '${filename}',
'Filename': '${filename}',
'acl': 'public-read',
'success_action_status': '201',
'AWSAccessKeyId' : '<?php echo $accessKeyId; ?>',
'policy': '<?php echo $policy; ?>',
'signature': '<?php echo $signature; ?>'
},
url : 'http://<?php echo $bucket; ?>.s3.amazonaws.com/',
flash_swf_url : '<?php echo $this->config->item('base_url'); ?>/plupload/js/plupload.flash.swf',
silverlight_xap_url : '<?php echo $this->config->item('base_url'); ?>/plupload/js/plupload.silverlight.xap',
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
],
});


$('#uploadfiles').click(function(e) {


var pattern = '<?php echo $blackListedWordsPattern; ?>';
var patt=new RegExp(pattern,"gi");
var value = $('#txtImageTitle').val();
if(value==""){
showAlertPopUp('Please enter title.');
return false;
}
if(patt.test(value)) //value is the value from the input feild
{
showAlertPopUp('Name contains a black listed words.');
return false;
}

if($("#category").val()==""){
showAlertPopUp('Please select category.');
return false;
}
$('#uploadfiles').hide();
$('#progressbar').show();

uploader.start();
e.preventDefault();

});
uploader.init();
uploader.splice();
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file){
up.settings.resize = {width : 190, height : 143, quality : 100};
}
else{
up.settings.resize = {width : 700, height : 450, quality : 100};
}
});

uploader.bind('FilesAdded', function(up, files) {
$.each(files, function(i, file) {
$('#filelist').html(
'<div style="float:right" id="' + file.id + '">' +
file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
'</div>');
});

up.refresh(); // Reposition Flash/Silverlight
});

uploader.bind('FileUploaded', function(up, file) {
$('#' + file.id + " b").html("100%");
if(!('thumb' in file)) {

file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();

}
});



uploader.bind('Error', function(up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);

up.refresh(); // Reposition Flash/Silverlight
});

});

最佳答案

multipart_params 用于随上传请求一起发送/发布数据,

要更改标题,您可以添加属性 - header,

希望这会有所帮助:

http://www.plupload.com/docs/Options#headers

关于jquery - Plupload 亚马逊 S3 缓存控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16480572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com