jquery - Plupload amazon S3 Cache-Control -
we uploading images using plupload amazon s3 bucket. need set cache-control uploaded file.
i have tried adding headers {'cache-control':'155520000'}, , adding under multipart_params. no luck.
the following code use. appreciated.
$(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 value input feild { showalertpopup('name contains 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 used send/post data along upload request,
for changing headers may add property - header,
hope :
Comments
Post a Comment