linux - Mono stream issue -



linux - Mono stream issue -

i want upload file on server using nancyfx. this:

var filestream = file.create(path_to_file); file.value.seek(0, seekorigin.begin); file.value.copyto(filestream); filestream.close();

also tried:

byte[] buffer; using (var memorystream = new memorystream()) { file.value.seek(0, seekorigin.begin); file.value.copyto(memorystream); buffer = memorystream.toarray(); } memorystream ms = new memorystream(buffer, 0, buffer.length); ms.position = 0; image img = image.fromstream(ms, true); img.save(path);

and this:

file.writeallbytes(coverpath, buffer);

on windows pc works great. on linux server, image saving, image content doesn't match original image. so, here images: original image, uploading: http://i.stack.imgur.com/mtse2.jpg saved image: http://i.stack.imgur.com/orkn1.jpg if image size < 900kb, image saving good, times there appears lines. please, help.

as understand have filestream , wanna save image

here peace of code works fine in windows 8 .net 4.5 , ubuntu 12 tls mono jit compiler version 2.10.8.1

class programme { static void main(string[] args) { string filename = @"img/mtse2.jpg"; string destimationimage = @"img/dest.jpg"; string apppath = appdomain.currentdomain.basedirectory; string pathtofile = path.combine(apppath, filename); if (!file.exists(pathtofile)) { console.writeline("cant find file {0}", pathtofile); console.readline(); return; } memorystream memorystream = new memorystream(); using (filestream filestream = file.open(pathtofile, filemode.open)) { console.writeline("source length: {0}", filestream.length); byte[] bytes = new byte[filestream.length]; filestream.read(bytes, 0, (int)filestream.length); memorystream.write(bytes, 0, (int)filestream.length); } console.writeline("memorystream length {0}", memorystream.length); string destpath = path.combine(apppath, destimationimage); copyasimage(destpath, memorystream); console.writeline("done! check file {0}",destpath); console.readline(); } private static void copyasimage(string filename, stream stream) { if (file.exists(filename)) { file.delete(filename); } image image = image.fromstream(stream, true, true); image.save(filename); } }

if still not work aware of sizes . in fact int int32 should ok byte array 2+gigs

linux image stream mono nancy

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -