How to sync Blob or byte[] array field from client SQLite to SQLServer through App Services? RRS feed

  • Question

  • Hello,

    I have a class Picture with various string fields as well as a byte[] field where I store a .png bitmap as a byte array.

    When my code executes this line: 

    await this.client.SyncContext.PushAsync();

    All fields sync with the Azure SQL Server tables and I can see all the data in the relevant table. No problems...

    EXCEPT the byte[] array field. Nothing ever gets pushed up to the server.

    I have found that Node.js, in dynamically discovering and adding fields to the tables, creates a nvarchar(max) field  for the byte[] array field on the class on the client side.

            [JsonProperty(PropertyName = "ImageBlob")]
            public byte[] ImageBlob

    I use this field on the client side to store .png image data as I want the user to have the app on multiple devices, sync'ing data through Azure App Services so that data is consistant across their devices as well as images associated with the various records.

    As I said, all other data in my SQLite tables sync without a problem EXCEPT the byte[] array field.

    How can a facilitate the .png blob data / byte[] array being sync'd with/into the Azure SQL Server database?

    Any other suggestions on solving this.


    Friday, February 14, 2020 4:29 PM

All replies

  • I'm not so sure this is related to the web app as much as it is related to reading complex structured data. Typically a byte[] cannot be used to store more complex data such as zip file, pdf file, or sometimes .png bitmap for SQL Server.

    Have you looked into storing the .png bitmap into a varbinary, which is the preferred approach?

    More info

    Friday, February 14, 2020 10:32 PM