遇到这个问题我想通过bump发送图像,但是bump api的最大块是256kb
if([[NSKeyedArchiver archivedDataWithRootObject:self.selectedImg]length] > 262144)
{
int dlen = [[NSKeyedArchiver
archivedDataWithRootObject:self.selectedImg] length];
NSLog(@"Sending data: %i bytes in %d chunks",dlen,
(int)ceil(((float)dlen / 262144.0f)));
for (int i=1; i <= (int)ceil(((float)dlen / 262144.0f)); i++) {
int maxr=0;
if ((262144*i) > dlen) {
maxr = dlen-(262144*(i-1));
} else {
maxr = 262144;
}
NSData *moveChunk = [[NSKeyedArchiver
archivedDataWithRootObject:self.selectedImg]
subdataWithRange:NSMakeRange(262144*(i-1),maxr)];
NSLog(@"Sending Chunk: %d, %d bytes",i,[moveChunk length]);
[bumpObject sendData:moveChunk];
}
}
else
{
//Data is 254kb or under
NSData *moveChunk = [NSKeyedArchiver
archivedDataWithRootObject:self.selectedImg];
[bumpObject sendData:moveChunk];
}
我如何将所有块编译在一起?
花了3个小时,但无法解决。