프로젝트 작업 중이며 s3에 파일을 업로드해야합니다. 여기 내 코드는 다음과 같습니다.Plupload Thumbnail
config = $.extend(Photo.Plupload.config, config);
var uploader = new plupload.Uploader({
runtimes:'flash,silverlight',
browse_button:config.select_button,
max_file_size:config.max_file_size,
url:'http://' + Photo.Album.Form.bucket + '.s3.amazonaws.com/',
flash_swf_url:'/assets/plupload/js/plupload.flash.swf',
silverlight_xap_url:'/assets/plupload/js/plupload.silverlight.xap',
init:{
FilesAdded:function (up, files) {
/*plupload.each(files, function (file) {
if (up.files.length > 1) {
up.removeFile(file);
}
});
if (up.files.length >= 1) {
$('#' + config.select_button).fadeOut('slow');
}*/
},
FilesRemoved:function (up, files) {
/*if (up.files.length < 1) {
$('#' + config.select_button).fadeIn('slow');
}*/
}
},
multi_selection:true,
multipart:true,
multipart_params:{
'key':config.key + '/${filename}',
'Filename':'${filename}', // adding this to keep consistency across the runtimes
'acl':config.acl,
'Content-Type':config.content_type,
'success_action_status':'201',
'AWSAccessKeyId':Photo.Album.Form.access_key_id,
'policy':Photo.Album.Form.policy,
'signature':Photo.Album.Form.signature
},
filters:[
{
title:config.filter_title,
extensions:config.filter_extentions
}
],
file_data_name:'file'
});
// instantiates the uploader
uploader.init();
// shows the progress bar and kicks off uploading
uploader.bind('FilesAdded', function (up, files) {
// add pseudofile to the sheet
console.log(files);
$.each(files, function (index, value) {
value.name = "thumb_" + value.name;
});
console.log(files);
console.log(up);
uploader.start();
});
// binds progress to progress bar
uploader.bind('UploadProgress', function (up, file) {
/*if (file.percent < 100) {
$('#progress_bar .ui-progress').css('width', file.percent + '%');
}
else {
$('#progress_bar .ui-progress').css('width', '100%');
$('span.ui-label').text('Complete');
}*/
});
// shows error object in the browser console (for now)
uploader.bind('Error', function (up, error) {
// unfortunately PLUpload gives some extremely vague
// Flash error messages so you have to use WireShark
// for debugging them (read the README)
alert('Что-то непонятное произошло. Firebug в помощь.');
console.log('Expand the error object below to see the error. Use WireShark to debug.');
console.log(error);
});
// when file gets uploaded
uploader.bind('FileUploaded', function (up, file) {
//console.log(up);
//console.log(file);
// save file location in the database
Photo.Album.Form.post(file)
up.refresh();
});
코드가 작동합니다. S3에 파일을 업로드하고 서버가 처리 할 수 있도록 보내는 유효한 응답을받습니다. 이미지 클라이언트 크기 조정도 작동합니다.
내가 지금하려는 것은 원본 파일과 함께 서버에 미리보기 이미지를 보내는 것입니다. 필자가 아는 한, plupload 초기화 프로그램에 여러 크기 조정 옵션을 입력 할 수 없습니다. 원본 파일뿐만 아니라 크기가 조정 된 버전이 S3로 전송되도록하려면 어떻게해야합니까? Amazon에서 파일 크기를 직접 조절할 수 있습니까?
파일을 다운로드하고 서버 크기를 조정하여 다른 해상도로 다시 업로드하는 옵션을 피하려고합니다.
미리 감사드립니다.