public
Description:
Homepage:
Clone URL: git://github.com/Squeegy/latest-chatty.git
Tweaked image posting code to reflect the curent API.
Squeegy (author)
Tue Aug 19 13:10:39 -0700 2008
commit  4501343bd42cbde79f3a87f579bc77a87c76ee4f
tree    ec78bcce95be71a545e81fde3484c22a64b2eef2
parent  dd520c1642e54f72fe1f49723c216b224a5a36c0
...
120
121
122
123
124
 
 
125
126
127
128
 
129
130
131
...
151
152
153
 
154
155
156
 
157
158
 
159
160
161
162
163
164
 
 
165
166
167
168
 
 
 
169
170
 
171
172
173
 
 
174
175
176
...
179
180
181
182
183
 
184
185
186
 
 
187
188
189
...
120
121
122
 
 
123
124
125
126
127
 
128
129
130
131
...
151
152
153
154
155
156
 
157
158
159
160
161
162
163
 
 
 
164
165
166
 
 
 
167
168
169
170
 
171
172
 
 
173
174
175
176
177
...
180
181
182
 
 
183
184
 
 
185
186
187
188
189
0
@@ -120,12 +120,12 @@
0
 
0
 - (void)imagePickerController:(UIImagePickerController *)picker 
0
         didFinishPickingImage:(UIImage *)image
0
-                  editingInfo:(NSDictionary *)editingInfo
0
-{
0
+                  editingInfo:(NSDictionary *)editingInfo {
0
+  
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
@@ -151,26 +151,27 @@
0
   
0
   NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
0
   NSLog(responseString);
0
+  NSLog(@"status: %d", statusCode);
0
 
0
   // Success! Return to previous view
0
-  if (statusCode == 200) {
0
+  if (statusCode == 201) {
0
     NSLog(@"Got a good response!");
0
     NSString *filename = @"";
0
+    
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
-    {
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
-      {      
0
+      NSRange filenameRangeEnd = [responseString rangeOfString:@"</success>" options:NSCaseInsensitiveSearch range:NSMakeRange(startLocation, [responseString length] - startLocation)];
0
+      
0
+      if (filenameRangeEnd.location != NSNotFound) {      
0
         filename = [responseString substringWithRange:NSMakeRange(startLocation, filenameRangeEnd.location - startLocation)];
0
-      }
0
+      }  
0
     }
0
-    if ([filename length] > 0)
0
-    {
0
+    
0
+    if ([filename length] > 0) {
0
       postContent.text = [[postContent text] stringByAppendingString:[NSString stringWithFormat:@"http://www.shackpics.com/viewer.x?file=%@", filename]];
0
     }
0
   }
0
@@ -179,11 +180,10 @@
0
   }
0
 }
0
 
0
-- (NSData*)shrinkImageByHalfAndJPEG:(UIImage *)picture
0
-{
0
+- (NSData*)shrinkImageByHalfAndJPEG:(UIImage *)picture {
0
   UIImage *retImage = picture;
0
-  if ((picture.size.width > 800) || (picture.size.height > 800))
0
-  {
0
+  
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;

Comments