cancel
Showing results for 
Search instead for 
Did you mean: 

issue when trying to write into SUPBigBinary from NSData

Former Member
0 Kudos

Dear all,

  when we try to write

into the SUPBigBinary

from NSData that consist of picture data more

than 10-20k bytes, the write

method acrually writes only 1kbyte(shows

only 1022bytes) of binary

data.

Please confirm that we need to do multiple writes to

SUPBigBinary,

maybe every time opening and closing the stream as

well.

Please check the below code we are using:

                UIImage *camerafile ;

                 @try{         camerafile  = [UIImage

imageNamed:@"green checkmark

64.png"];

NSData *cameradata = [UIImagePNGRepresentation:camerafile];

                                

long test=cameradata.length;

long long size=[cameradata.length];

long long iter= size/1000 + 1;

                 [FIFIDB synchronise];     //shell MBO           

FIAddPictureList *returnDummies = [FIAddPicture findAll];

                                 if ([returnDummies length] > 0)

                                

{

                                       for (FIAddPicture *oneRec in returnDummies)

                                      

{

                                        FIAddPicture *fap = oneRec;

                

SUPBigBinary *fileContent=fap.FILE_CONTENT;

//[fileContent copyFromFile:@"green checkmark 64.png"];

                                   

[fileContent openForWrite: 0];  //SUPLong size 1000

for(int j=0; j<iter;++j)

{

[fileContent

write:cameradata];

[fileContent

flush];

}

                 

[fileContent close];

                                                

[fap create:@"pic1"

withIV_OBJECT_ID:@"0005000002"

withIV_FILE_EXT:@"jpeg"];

                                                

[fap  save];

                                                 [fap  submitPending]; [FIFIDB synchronize];

                                                

break;

                                     }                     

}

                 }

                 @catch (NSException *exception)

{

                 NSLog(@"FAILED: updating record");

                

NSLog(@"%@: %@", [exception name],[exception reason]);

                

return;     }

                 [camerafile release];

Accepted Solutions (1)

Accepted Solutions (1)

brenton_ocallaghan
Active Participant
0 Kudos

Hi Fiston,

I think this is a similar question to the one I have answered here. but to recap, to get your binary data to transfer you need to save your entity before setting the binary data. An example would be as follows:

   StringTestData *newData = [StringTestData getInstance];

    [newData save];

   

    SUPBigBinary *text = newData.TEXT;

   

    NSData *myData = [NSData dataWithData:someDataHere];

   

    [text openForWrite:[myData length]];

    [text write:myData];

    [text close];

   

    [newData save];

    [newData submitPending];

   

    [StringTestStringTestDB synchronize];

Hope that helps,

Brenton.

Former Member
0 Kudos

Hi Brenton, We were able to resolve this issue using the suggestion you've given. Thanks a lot!

Fiston

Answers (0)