Last post Mar 14, 2019 05:31 PM by PatriceSc
Mar 14, 2019 09:04 AM|reza-2017|LINK
public ActionResult DownloadFile()
return File("~/Upload/IMG/769519384MasterDaftar.pdf", MediaTypeNames.Application.Pdf);
error message :
This pdf doument might not be display correctly !
Mar 14, 2019 09:08 AM|PatriceSc|LINK
Knowing what shows this error could help. According to https://github.com/mozilla/pdf.js/issues/2084 it seems to be shown by the pdf.js library in which case a forum for this library could be better
(or see what triggers that in the source code ?)
Mar 14, 2019 09:12 AM|reza-2017|LINK
another file also cannot returned
i can not download file from project folder
string path = HostingEnvironment.MapPath("~/Upload/IMG/");
var decrypted = AesCryptoService.DecryptStringFromBytes_Aes(image);
fileBytes = System.IO.File.ReadAllBytes(path + decrypted);
fileName = Rand.DateTimeTick() + ".jpeg";
Mar 14, 2019 09:15 AM|reza-2017|LINK
original image size is 4.5 mb
when download is complete
image size change to 8.68 mb and cannot show image
Mar 14, 2019 10:09 AM|PatriceSc|LINK
So it seems the content is sended back twice ? You are using Response.BinaryWrite as well ???
I would try with a text file with content such as "abcdefgh" text. It is then easy to check that you still have that once uploaded and when downloaded again (rather than "abcdefghabcdefgh" maybe ?)
Else show maybe the full code for your action if not that huge so that we can see exactly what you are doing.
Edit: is the file size on the server ok ? If not the issue could be in your uploading code.
Mar 14, 2019 10:19 AM|reza-2017|LINK
My Code :
public FileStreamResult StreamFileFromDisk()
string path = AppDomain.CurrentDomain.BaseDirectory + "Upload/IMG/";
string fileName = "3_vpz2t3xddpl1732502976.jpg";
return File(new FileStream(path + fileName, FileMode.Open), "image/jpeg", fileName);
//string path = AppDomain.CurrentDomain.BaseDirectory + "Upload/IMG/";
//string fileName = "a.txt";
//return File(new FileStream(path + fileName, FileMode.Open), "text/plain", fileName);
a.txt is working true but images size is duplicate
i want to download image from upload folder
Mar 14, 2019 10:44 AM|PatriceSc|LINK
And so you checked the size of the file on your server disk as suggested ? If the size is not correct, the issue could be in your
Mar 14, 2019 10:55 AM|reza-2017|LINK
Mar 14, 2019 12:10 PM|PatriceSc|LINK
Ok but don't stop just there. The next logical step is to look at the actual file content. It should really help to understand from where it comes (some kind of trace you added somewhere ?)
Edit: generally speaking you don't debug an app by just looking at the code. You look at what actually happens to gradually narrow down what happens until the last possibility is left. Here looking at the actual content you get should give a real clue about
what happens and why the payload is not what you expect.
Mar 14, 2019 05:07 PM|reza-2017|LINK
.... dont support this format !
public FileResult DownloadF()
Mar 14, 2019 05:31 PM|PatriceSc|LINK
I meant really looking at the actual content. Previously you tested with a file containing maybe "abc" but still ending up in serving 112 bytes. I would look like at this 112 byte content. I expect it could be something such as :
Some extra text content here.abc
If not printable I would dump the bytes, to see which https://en.wikipedia.org/wiki/List_of_file_signatures signature it is.
It gave me the idea to give this a quick try but compressing a text file with "abc" gives me a 111 bytes file. Could it be that your upload code stores content as a zip file and you forgot to uncompress those files before sending them back to the browser