How to Use Crosslight to Save Images via EntityContextProvider

14 replies. Last post: April 16, 2015 9:00 AM by Arief Handany
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Jimmy TungolMember

Hi,

How are images being sent via EntityContextProvider? Based on the MyInventory_WebApi sample, there are four (4) properties added to a partial class that extends the Item within the core project for the mobile platforms. Two of these properties contain the actual data of type byte[] and two are string properties resolving the Url for large and thumbnail image files. We've implemented the same set of properties in order to add/edit/delete an image for a selected record via form editor; however, the image files are not being saved on the disk. Although, the image path is being saved on the database the byte[] data for the LargeImage and ThumbnailImage properties are not being sent to the server. We've confirmed this by debugging the partial class for the Web Api Controller, and noticed that the EntityContextProvider.Files collection is null.

That being the case, please note that the Image we're trying to modify is coming from a related entity and NOT from the Item itself. Here's a code snippet to show you how things are being done from the core. The following codes assigns the new file name for the Photo, while ThumbnailImage and LargeImage contain the sets of byte[]. While the file name is being saved to the database successfully, the contents of the byte[] are not being sent to the server.

this.Item.Details.Photo = Guid.NewGuid().ToString("n") + ".jpg";
this.Item.Details.ThumbnailImage = imagePicker.Result.ThumbnailImageData;
this.Item.Details.LargeImage = imagePicker.Result.ImageData;

We even tried creating the resolving properties on the same class with that of the Item, resulting to the code below, but still not working.

this.Item.Details.Photo = Guid.NewGuid().ToString("n") + ".jpg";
this.Item.ThumbnailImage = imagePicker.Result.ThumbnailImageData;
this.Item.LargeImage = imagePicker.Result.ImageData;

Is there anything else we need to do here, aside from creating just the properties and assigning the results? Please advise.

All times are GMT -5. The time now is 12:43 AM.
Previous Next