0
- (void)imagePickerController:(UIImagePickerController *)picker
0
didFinishPickingImage:(UIImage *)image
0
- editingInfo:(NSDictionary *)editingInfo
0
+ editingInfo:(NSDictionary *)editingInfo {
0
NSLog(@"User picked an image.");
0
[picker dismissModalViewControllerAnimated:YES];
0
[[picker view] setHidden:YES];
0
- NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:
@"http://shackchatty.com/images"]] autorelease];
0
+ NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:
[Feed urlStringWithPath:@"images.xml"]]] autorelease];
0
[request setHTTPMethod:@"POST"];
0
//Think I'll want to use this for images larger than 800 or 1024 pixels or something, since Base64 encoding makes the data a lot larger.
0
//NSData *imageData = [self shrinkImageByHalfAndJPEG:image];
0
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
0
+ NSLog(@"status: %d", statusCode);
0
// Success! Return to previous view
0
- if (statusCode == 20
0) {
0
+ if (statusCode == 20
1) {
0
NSLog(@"Got a good response!");
0
NSString *filename = @"";
0
//Parse new filename from response.
0
//There's a comment that has it in the data, we'll use this for now.
0
//<!-- filename: file_hre1vo65wybn41borox4.png -->
0
- NSRange filenameRangeStart = [responseString rangeOfString:@"<!-- filename: "];
0
- if (filenameRangeStart.location != NSNotFound)
0
+ NSRange filenameRangeStart = [responseString rangeOfString:@"<success>"];
0
+ if (filenameRangeStart.location != NSNotFound) {
0
int startLocation = filenameRangeStart.location + filenameRangeStart.length;
0
- NSRange filenameRangeEnd = [responseString rangeOfString:@"-->" options:NSCaseInsensitiveSearch range:NSMakeRange(startLocation, [responseString length] - startLocation)];
0
- if (filenameRangeEnd.location != NSNotFound)
0
+ NSRange filenameRangeEnd = [responseString rangeOfString:@"</success>" options:NSCaseInsensitiveSearch range:NSMakeRange(startLocation, [responseString length] - startLocation)];
0
+ if (filenameRangeEnd.location != NSNotFound) {
0
filename = [responseString substringWithRange:NSMakeRange(startLocation, filenameRangeEnd.location - startLocation)];
0
- if ([filename length] > 0)
0
+ if ([filename length] > 0) {
0
postContent.text = [[postContent text] stringByAppendingString:[NSString stringWithFormat:@"http://www.shackpics.com/viewer.x?file=%@", filename]];
0
-- (NSData*)shrinkImageByHalfAndJPEG:(UIImage *)picture
0
+- (NSData*)shrinkImageByHalfAndJPEG:(UIImage *)picture {
0
UIImage *retImage = picture;
0
- if ((picture.size.width > 800) || (picture.size.height > 800))
0
+ if ((picture.size.width > 800) || (picture.size.height > 800)) {
0
CGImageRef imageRef = [picture CGImage];
0
size_t newHeight = picture.size.height *.5;
0
size_t newWidth = picture.size.width * .5;