locked
Can Image be saved from LightSwitch? RRS feed

  • Question

  • Hello!

    is it possible to save image from LS - ideally in exactly the same format it was attached from?

    sounds easy, but i am unable to solve this and client cant understand why is that a problem :)

    any ideas?

    THANX!

    Monday, June 18, 2012 5:12 PM

Answers

  • I did this with a sl control. What I did what serialize image and filename in the binary.  Then reversed it.  Added a download button to save.  Not ideal, but works. You could create a business control also to save having to serialize the filename with the image and instead save the file name as a column in the table. I ran into issues building business controls on my x64 system, so did finish that.
    Monday, June 18, 2012 8:58 PM

All replies

  • Hi Miroslav

    By default lightswitch control does not allow to save the existing image file. But you can upload image and download it from lightswitch.

    Please go through below thread demonstrated by Michael Washington regarding saving file to file system to lightswitch.

    http://lightswitchhelpwebsite.com/Blog/tabid/61/tagid/21/WCF-RIA-Service.aspx

    http://blogs.msdn.com/b/rmattsampson/archive/2011/05/23/how-to-import-and-store-a-data-file.aspx

    Hope this help..

    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.blogspot.in

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    Monday, June 18, 2012 5:37 PM
  • Rashmi,

    thanx for your post.

    Client just wants to be able to save images that a re attached from LightSwitch - and expects some easy-to-use functionality, simmilar to what he had at the time of attaching the image.

    but it will not be possible?

    Monday, June 18, 2012 5:54 PM
  • Hi Miroslav

    Then you have to integrate your own silverlight custom control which will allow you to attach image from lightswitch and download it.

    Let me investigate something, If i found then i will update here.

    Regards


    Rashmi Ranjan Panigrahi
    www.lightswitchspecial.blogspot.in

    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”.
    This will help other users to find their answer quickly.

    Monday, June 18, 2012 6:05 PM
  • Hey Rashmi,

    there's no way to extract it from database?

    Monday, June 18, 2012 6:09 PM
  • Not out of the box. Like Rashmi said, you have to build you own custom control or hook into a Button's Click event to save image data.

    The reason why the Image controls do not do this is that the data is not saved in any particular file format. It's saved an the array of pixels that make up the image. It would have to know what format (e.g. PNG, JPG, etc...), convert it to that format, and then save it to disk. I'm fairly certain Silverlight, by default, does not have any conversion abilities built-in, so any type of format conversion would need to be custom.


    Justin Anderson, LightSwitch Development Team

    Monday, June 18, 2012 8:47 PM
    Moderator
  • I did this with a sl control. What I did what serialize image and filename in the binary.  Then reversed it.  Added a download button to save.  Not ideal, but works. You could create a business control also to save having to serialize the filename with the image and instead save the file name as a column in the table. I ran into issues building business controls on my x64 system, so did finish that.
    Monday, June 18, 2012 8:58 PM
  • Thanx!

    so, it's best to use some totally custom control and than start saving images within in?

    ugh crazy but we have to make it happen :)

    Monday, June 18, 2012 9:15 PM
  • I would not say best. The easiest way is add a button next to your image control.  You can save the byte[] to file. The issue then just becomes what to name it.  Also, you then need to know if it a jpg or png?  I suppose you could figure that out from byte signature, but not sure how to do that.
    Tuesday, June 19, 2012 2:36 AM