c# - having trouble with getting file from drop box and saving on my server, please help me -


here java script code choose file drop box, when try save file server using c# able see file on server empty.when trying open file file giving error 'file corrupted'. using signalr.

options = {      // required. called when user selects item in chooser.     success: function (files) {         alert("here's file link: " + files[0].link)         hub.server.servermethod(files[0].link, files[0].name);     },      // optional. called when user closes dialog without selecting file     // , not include parameters.     cancel: function () {      },      // optional. "preview" (default) preview link document sharing,     // "direct" expiring link download contents of file. more     // information link types, see link types below.     linktype: "preview", // or "direct"      // optional. value of false (default) limits selection single file, while     // true enables multiple file selection.     multiselect: false, // or true      // optional. list of file extensions. if specified, user     // able select files these extensions. may specify     // file types, such "video" or "images" in list. more information,     // see file types below. default, extensions allowed.     extensions: ['.csv', '.xls', '.tsv', '.xlsx', '.txt'], }; var button = dropbox.createchoosebutton(options); $('#container').append(button); function some() {     dropbox.choose(options); } 

server method code is

       // execute request            httpwebresponse response = (httpwebresponse)                request.getresponse();            // read data via response stream            stream resstream = response.getresponsestream();            string tempstring = null;            int count = 0;            byte[] buffer = new byte[32 * 1024];            stringbuilder sb = new stringbuilder();                       {                // fill buffer data                count = resstream.read(buffer, 0, buffer.length);                 // make sure read data                if (count != 0)                {                    // translate bytes ascii text                    tempstring = encoding.ascii.getstring(buffer, 0, count);                     // continue building string                    sb.append(tempstring);                }            }            while (count > 0); // more data read?            using (filestream fs = file.create(system.configuration.configurationmanager.appsettings.getvalues("documentpath").first().tostring() + filename))            {                // byte[] bufer = new byte[32 * 1024];                fs.write(buffer, 0, buffer.length);            } 

you're setting linktype "preview", gives link preview page file, , not file content itself. if want direct access file content, e.g., , programmatically download content server, seems you're trying do, should use "direct" linktype.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -