If the file is larger than that, the end is truncated and the content is not valid anymore. Up to now, the code only reads 500,000 bytes for each file. These images were saved in an old CMS system so I do wonder if the way that they were saved is the cause? It's only this selection of images that are affected. However the issue with the JPEG files being altered to PNG is still ongoing. I have now updated the number of allowed bytes which has resulted in viable images. I'm not sure what else I can do to ensure that this identifies the correct file type. I have also tried converting this to use MemoryStream instead. Using (var br = new BinaryReader(responseStream)) Var responseStream = imageResponse.GetResponseStream() Var imageResponse = imageRequest.GetResponse() Var imageRequest = (HttpWebRequest)WebRequest.Create(fullPath) This is my method:- public byte Get(string fullPath) So, it's the conversion from the original image to byte array that is mysteriously updating the file type. Using some code that I copied from the web, I am able to identify the file extension from the image byte array after it is built. png files which when they arrive at the CDN are blank. I have now used this successfully hundreds of times, however on migrating a particular set of images, I've noticed that these Jpeg files are identifying as. I have a method that takes a web-based image, converts it into a byte array and then passes that to a CDN as an image.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |