scala - Issue serving static files in spray -


i'm having problems serving static files route @ core using spray 1.3.2:

ctx.withhttpresponseheadersmapped(hm => hm ++ list(`content-disposition`("attachment",    map(("filename", attachment.name),    `content-length`(attachment.bytes.length)))    .withhttpresponseentitymapped { e =>      httpentity(new contenttype(        mediatypes.forextension(attachment.name.split('.').last.tolowercase).getorelse(mediatypes.`application/octet-stream`), none), e.data)  //also tried mediatypes.`application/octet-stream` default    }    .complete(attachment.bytes) 

where attachment.name string , attachment.bytes array[byte].

in way i'm able download file represented array[byte] browser interface, problem when file in excel formats (xls, xlsx) downloaded file seem corrupted during process , wont open.
strange thing corrupted files dimension of downloaded copy bigger original , in browser console possible notice transfer-encoding set chunked content-length header removed.
removing specific media type has no effect.

i can't find solution make excel files working smooth piece of code.

i don't understand transfer-encoding set chunked , file size seems not cause because it's possible serve big file without issue other formats (pdf, txt, jpeg, ...)

if can give hint on happening appreciate it, thanks.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -