How do you know that it is sqlite that is corrupting the images, could
your conversion to nsdata (or elsewhere prior to writing to teh DB) be
the culprit?

Given your schema if a record has become corrupt then the following
two columns (the data for which which would be stored contiguously
after the blob) would also be corrupt.


Paul
www.sandersonforensics.com
skype: r3scue193
twitter: @sandersonforens
Tel +44 (0)1326 572786
http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit
-Forensic Toolkit for SQLite
email from a work address for a fully functional demo licence


On 17 February 2016 at 22:35, Simon Slavin <slavins at bigfraud.org> wrote:
>
> On 17 Feb 2016, at 10:23pm, Rooney, Joe <Joseph.Rooney at commscope.com> 
> wrote:
>
>>  1.  The database table has four fields: Employee GUID (varchar), 
>> EmployeePic (Blob), isPicAvail (Bool) and picDate (int).
>
> Store the BLOB field at the end of the row.  This will make accessing the two 
> fields currently after it faster.
>
>> I use the same UPDATE call, as above in 4. I don't delete the previous Blob, 
>> just assuming that SQLite will take care of those details.
>
> It should do.
>
>> The process works well except that occasionally two images end up getting 
>> corrupted. Not just one, it always happens in pairs. I get the upper part of 
>> both images, with just the lower part showing garbage.
>
> Run PRAGMA integrity_check() on the database and tell us if it finds errors.
>
> If possible copy the database to a computer and download and use the analysis 
> utility from the SQLite download page.
>
>> The questions:
>>
>>  *   Is this general approach wise?
>>  *   Should I clear the old Blob before rewriting the new image, or should I 
>> simply delete the old rec and write a new one?
>>  *   Should I store the mime string coming back in the JSON return rather 
>> than converting the string to an image, and then converting it every time we 
>> need to display the image.
>>  *   Should I simply store a string link to the image and load that whenever 
>> it is needed.
>
> Yes.
> No, you should be able to just rewrite it.
> You wrote you were storing the NSData.  That's not just the bytes of the 
> image itself.  It doesn't matter which you do but be clear which you're 
> doing.  Storing MIME is probably a waste of space.
> I think you should store the content, not a link.
>
> Questions from me:
>
> What language are you writing in ?
> What API are you using to access SQLite ?
> Check the first few bytes of a BLOB and be certain that they are the first 
> few bytes of what would be in an image file stored on disk.
> How are you writing your BLOB ?  Are you writing the whole field at once or 
> are you using the specialist BLOB calls ?
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to