Thursday 15 March 2012

javascript - Plupload chunk size renaming file to Blob -



javascript - Plupload chunk size renaming file to Blob -

i'm using plupload in order download file. configuration have folowing :

$("#uploaddata").pluploadqueue({ // general settings runtimes: 'html5,flash,silverlight,html4', url: serviceurl, // maximum file size max_file_size: '50mb', chunk_size: '1mb', max_file_count: 50, unique_names: true, // resize images on clientside if can resize: { width: 200, height: 200, quality: 90, crop: true // crop exact dimensions }, // specify files browse filters: [ { title: "documents excel", extensions: "xlsx" } ], init: { filesadded: function (up, files) { up.start(); }, uploadcomplete: function (up, files) { if (up.total.uploaded == up.files.length) { $(".plupload_buttons").css("display", "inline"); $(".plupload_upload_status").css("display", "inline"); up.init(); } } },

the problem have when upload file bigger 1mb, don't receive right name, instead receive blob name. exemple, name of file "test.xlsx" , size 2mb, receive, on server side, "blob" name , not test.

limitation, i'm not allowed alter chuck size limitation on client. how can right name.

thank help.

code used receive info on server side :

[system.web.mvc.httppost] public actionresult uploaddata(int? chunk, string name) { var fileupload = request.files[0]; if (session["updatafiles"] == null) { session["updatafiles"] = new list<fileuploadviewmodel>(); } session["updatafiles"] = updatetempdataupload(fileupload.filename, name, (list<fileuploadviewmodel>)session["updatafiles"]); uploadfile(chunk, name); homecoming content("chunk uploaded", "text/plain"); } private void uploadfile(int? filechunk, string filename) { var fileupload = request.files[0]; var uploadpath = server.mappath("~/app_data"); var fullpath = path.combine(uploadpath, filename); filechunk = filechunk ?? 0; using (var fs = new filestream(path.combine(uploadpath, filename), filechunk == 0 ? filemode.create : filemode.append, fileaccess.write, fileshare.readwrite)) { var buffer = new byte[fileupload.inputstream.length]; fileupload.inputstream.read(buffer, 0, buffer.length); fs.write(buffer, 0, buffer.length); fs.close(); } }

when check name in request.file object, it's blob , not actual name.

this issue described in detail on github. might little confusing, understand:

$_files[ 'name' ] obligatorily 'blob' if utilize chunks. they seem claim $_request[ 'name' ] should have real name, users seem disagree. as workaround proposed send filename along in form field or url parameter (using illustration beforeupload event set information). can set multipart_params , store info on file object added before or @ field in html info @ point.

javascript c# model-view-controller plupload

No comments:

Post a Comment