GCDWebUploader.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /*
  2. Copyright (c) 2012-2014, Pierre-Olivier Latour
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * The name of Pierre-Olivier Latour may not be used to endorse
  12. or promote products derived from this software without specific
  13. prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #import <TargetConditionals.h>
  26. #if TARGET_OS_IPHONE
  27. #import <UIKit/UIKit.h>
  28. #else
  29. #import <SystemConfiguration/SystemConfiguration.h>
  30. #endif
  31. #import "GCDWebUploader.h"
  32. #import "GCDWebServerDataRequest.h"
  33. #import "GCDWebServerMultiPartFormRequest.h"
  34. #import "GCDWebServerURLEncodedFormRequest.h"
  35. #import "GCDWebServerDataResponse.h"
  36. #import "GCDWebServerErrorResponse.h"
  37. #import "GCDWebServerFileResponse.h"
  38. @interface GCDWebUploader () {
  39. @private
  40. NSString* _uploadDirectory;
  41. NSArray* _allowedExtensions;
  42. BOOL _allowHidden;
  43. NSString* _title;
  44. NSString* _header;
  45. NSString* _prologue;
  46. NSString* _epilogue;
  47. NSString* _footer;
  48. }
  49. @end
  50. @implementation GCDWebUploader (Methods)
  51. // Must match implementation in GCDWebDAVServer
  52. - (BOOL)_checkSandboxedPath:(NSString*)path {
  53. return [[path stringByStandardizingPath] hasPrefix:_uploadDirectory];
  54. }
  55. - (BOOL)_checkFileExtension:(NSString*)fileName {
  56. if (_allowedExtensions && ![_allowedExtensions containsObject:[[fileName pathExtension] lowercaseString]]) {
  57. return NO;
  58. }
  59. return YES;
  60. }
  61. - (NSString*) _uniquePathForPath:(NSString*)path {
  62. if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
  63. NSString* directory = [path stringByDeletingLastPathComponent];
  64. NSString* file = [path lastPathComponent];
  65. NSString* base = [file stringByDeletingPathExtension];
  66. NSString* extension = [file pathExtension];
  67. int retries = 0;
  68. do {
  69. if (extension.length) {
  70. path = [directory stringByAppendingPathComponent:[[base stringByAppendingFormat:@" (%i)", ++retries] stringByAppendingPathExtension:extension]];
  71. } else {
  72. path = [directory stringByAppendingPathComponent:[base stringByAppendingFormat:@" (%i)", ++retries]];
  73. }
  74. } while ([[NSFileManager defaultManager] fileExistsAtPath:path]);
  75. }
  76. return path;
  77. }
  78. - (GCDWebServerResponse*)listDirectory:(GCDWebServerRequest*)request {
  79. NSString* relativePath = [[request query] objectForKey:@"path"];
  80. NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
  81. BOOL isDirectory = NO;
  82. if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
  83. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
  84. }
  85. if (!isDirectory) {
  86. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_BadRequest message:@"\"%@\" is not a directory", relativePath];
  87. }
  88. NSString* directoryName = [absolutePath lastPathComponent];
  89. if (!_allowHidden && [directoryName hasPrefix:@"."]) {
  90. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Listing directory name \"%@\" is not allowed", directoryName];
  91. }
  92. NSError* error = nil;
  93. NSArray* contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:absolutePath error:&error];
  94. if (contents == nil) {
  95. return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed listing directory \"%@\"", relativePath];
  96. }
  97. NSMutableArray* array = [NSMutableArray array];
  98. for (NSString* item in [contents sortedArrayUsingSelector:@selector(localizedStandardCompare:)]) {
  99. if (_allowHidden || ![item hasPrefix:@"."]) {
  100. NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[absolutePath stringByAppendingPathComponent:item] error:NULL];
  101. NSString* type = [attributes objectForKey:NSFileType];
  102. if ([type isEqualToString:NSFileTypeRegular] && [self _checkFileExtension:item]) {
  103. [array addObject:@{
  104. @"path": [relativePath stringByAppendingPathComponent:item],
  105. @"name": item,
  106. @"size": [attributes objectForKey:NSFileSize]
  107. }];
  108. } else if ([type isEqualToString:NSFileTypeDirectory]) {
  109. [array addObject:@{
  110. @"path": [[relativePath stringByAppendingPathComponent:item] stringByAppendingString:@"/"],
  111. @"name": item
  112. }];
  113. }
  114. }
  115. }
  116. return [GCDWebServerDataResponse responseWithJSONObject:array];
  117. }
  118. - (GCDWebServerResponse*)downloadFile:(GCDWebServerRequest*)request {
  119. NSString* relativePath = [[request query] objectForKey:@"path"];
  120. NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
  121. BOOL isDirectory = NO;
  122. if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
  123. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
  124. }
  125. if (isDirectory) {
  126. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_BadRequest message:@"\"%@\" is a directory", relativePath];
  127. }
  128. NSString* fileName = [absolutePath lastPathComponent];
  129. if (([fileName hasPrefix:@"."] && !_allowHidden) || ![self _checkFileExtension:fileName]) {
  130. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Downlading file name \"%@\" is not allowed", fileName];
  131. }
  132. if ([self.delegate respondsToSelector:@selector(webUploader:didDownloadFileAtPath: )]) {
  133. dispatch_async(dispatch_get_main_queue(), ^{
  134. [self.delegate webUploader:self didDownloadFileAtPath:absolutePath];
  135. });
  136. }
  137. return [GCDWebServerFileResponse responseWithFile:absolutePath isAttachment:YES];
  138. }
  139. - (GCDWebServerResponse*)uploadFile:(GCDWebServerMultiPartFormRequest*)request {
  140. NSRange range = [[request.headers objectForKey:@"Accept"] rangeOfString:@"application/json" options:NSCaseInsensitiveSearch];
  141. NSString* contentType = (range.location != NSNotFound ? @"application/json" : @"text/plain; charset=utf-8"); // Required when using iFrame transport (see https://github.com/blueimp/jQuery-File-Upload/wiki/Setup)
  142. GCDWebServerMultiPartFile* file = [request firstFileForControlName:@"files[]"];
  143. if ((!_allowHidden && [file.fileName hasPrefix:@"."]) || ![self _checkFileExtension:file.fileName]) {
  144. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploaded file name \"%@\" is not allowed", file.fileName];
  145. }
  146. NSString* relativePath = [[request firstArgumentForControlName:@"path"] string];
  147. NSString* absolutePath = [self _uniquePathForPath:[[_uploadDirectory stringByAppendingPathComponent:relativePath] stringByAppendingPathComponent:file.fileName]];
  148. if (![self _checkSandboxedPath:absolutePath]) {
  149. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
  150. }
  151. if (![self shouldUploadFileAtPath:absolutePath withTemporaryFile:file.temporaryPath]) {
  152. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploading file \"%@\" to \"%@\" is not permitted", file.fileName, relativePath];
  153. }
  154. NSError* error = nil;
  155. if (![[NSFileManager defaultManager] moveItemAtPath:file.temporaryPath toPath:absolutePath error:&error]) {
  156. return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed moving uploaded file to \"%@\"", relativePath];
  157. }
  158. if ([self.delegate respondsToSelector:@selector(webUploader:didUploadFileAtPath:)]) {
  159. dispatch_async(dispatch_get_main_queue(), ^{
  160. [self.delegate webUploader:self didUploadFileAtPath:absolutePath];
  161. });
  162. }
  163. return [GCDWebServerDataResponse responseWithJSONObject:@{} contentType:contentType];
  164. }
  165. - (GCDWebServerResponse*)moveItem:(GCDWebServerURLEncodedFormRequest*)request {
  166. NSString* oldRelativePath = [request.arguments objectForKey:@"oldPath"];
  167. NSString* oldAbsolutePath = [_uploadDirectory stringByAppendingPathComponent:oldRelativePath];
  168. BOOL isDirectory = NO;
  169. if (![self _checkSandboxedPath:oldAbsolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:oldAbsolutePath isDirectory:&isDirectory]) {
  170. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", oldRelativePath];
  171. }
  172. NSString* newRelativePath = [request.arguments objectForKey:@"newPath"];
  173. NSString* newAbsolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:newRelativePath]];
  174. if (![self _checkSandboxedPath:newAbsolutePath]) {
  175. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", newRelativePath];
  176. }
  177. NSString* itemName = [newAbsolutePath lastPathComponent];
  178. if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) {
  179. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Moving to item name \"%@\" is not allowed", itemName];
  180. }
  181. if (![self shouldMoveItemFromPath:oldAbsolutePath toPath:newAbsolutePath]) {
  182. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Moving \"%@\" to \"%@\" is not permitted", oldRelativePath, newRelativePath];
  183. }
  184. NSError* error = nil;
  185. if (![[NSFileManager defaultManager] moveItemAtPath:oldAbsolutePath toPath:newAbsolutePath error:&error]) {
  186. return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed moving \"%@\" to \"%@\"", oldRelativePath, newRelativePath];
  187. }
  188. if ([self.delegate respondsToSelector:@selector(webUploader:didMoveItemFromPath:toPath:)]) {
  189. dispatch_async(dispatch_get_main_queue(), ^{
  190. [self.delegate webUploader:self didMoveItemFromPath:oldAbsolutePath toPath:newAbsolutePath];
  191. });
  192. }
  193. return [GCDWebServerDataResponse responseWithJSONObject:@{}];
  194. }
  195. - (GCDWebServerResponse*)deleteItem:(GCDWebServerURLEncodedFormRequest*)request {
  196. NSString* relativePath = [request.arguments objectForKey:@"path"];
  197. NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
  198. BOOL isDirectory = NO;
  199. if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
  200. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
  201. }
  202. NSString* itemName = [absolutePath lastPathComponent];
  203. if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) {
  204. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting item name \"%@\" is not allowed", itemName];
  205. }
  206. if (![self shouldDeleteItemAtPath:absolutePath]) {
  207. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting \"%@\" is not permitted", relativePath];
  208. }
  209. NSError* error = nil;
  210. if (![[NSFileManager defaultManager] removeItemAtPath:absolutePath error:&error]) {
  211. return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed deleting \"%@\"", relativePath];
  212. }
  213. if ([self.delegate respondsToSelector:@selector(webUploader:didDeleteItemAtPath:)]) {
  214. dispatch_async(dispatch_get_main_queue(), ^{
  215. [self.delegate webUploader:self didDeleteItemAtPath:absolutePath];
  216. });
  217. }
  218. return [GCDWebServerDataResponse responseWithJSONObject:@{}];
  219. }
  220. - (GCDWebServerResponse*)createDirectory:(GCDWebServerURLEncodedFormRequest*)request {
  221. NSString* relativePath = [request.arguments objectForKey:@"path"];
  222. NSString* absolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:relativePath]];
  223. if (![self _checkSandboxedPath:absolutePath]) {
  224. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
  225. }
  226. NSString* directoryName = [absolutePath lastPathComponent];
  227. if (!_allowHidden && [directoryName hasPrefix:@"."]) {
  228. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory name \"%@\" is not allowed", directoryName];
  229. }
  230. if (![self shouldCreateDirectoryAtPath:absolutePath]) {
  231. return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory \"%@\" is not permitted", relativePath];
  232. }
  233. NSError* error = nil;
  234. if (![[NSFileManager defaultManager] createDirectoryAtPath:absolutePath withIntermediateDirectories:NO attributes:nil error:&error]) {
  235. return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed creating directory \"%@\"", relativePath];
  236. }
  237. if ([self.delegate respondsToSelector:@selector(webUploader:didCreateDirectoryAtPath:)]) {
  238. dispatch_async(dispatch_get_main_queue(), ^{
  239. [self.delegate webUploader:self didCreateDirectoryAtPath:absolutePath];
  240. });
  241. }
  242. return [GCDWebServerDataResponse responseWithJSONObject:@{}];
  243. }
  244. @end
  245. @implementation GCDWebUploader
  246. @synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, allowHiddenItems=_allowHidden,
  247. title=_title, header=_header, prologue=_prologue, epilogue=_epilogue, footer=_footer;
  248. - (instancetype)initWithUploadDirectory:(NSString*)path {
  249. if ((self = [super init])) {
  250. NSBundle* siteBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"GCDWebUploader" ofType:@"bundle"]];
  251. if (siteBundle == nil) {
  252. #if !__has_feature(objc_arc)
  253. [self release];
  254. #endif
  255. return nil;
  256. }
  257. _uploadDirectory = [[path stringByStandardizingPath] copy];
  258. #if __has_feature(objc_arc)
  259. GCDWebUploader* __unsafe_unretained server = self;
  260. #else
  261. __block GCDWebUploader* server = self;
  262. #endif
  263. // Resource files
  264. [self addGETHandlerForBasePath:@"/" directoryPath:[siteBundle resourcePath] indexFilename:nil cacheAge:3600 allowRangeRequests:NO];
  265. // Web page
  266. [self addHandlerForMethod:@"GET" path:@"/" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  267. #if TARGET_OS_IPHONE
  268. NSString* device = [[UIDevice currentDevice] name];
  269. #else
  270. #if __has_feature(objc_arc)
  271. NSString* device = CFBridgingRelease(SCDynamicStoreCopyComputerName(NULL, NULL));
  272. #else
  273. NSString* device = [(id)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease];
  274. #endif
  275. #endif
  276. NSString* title = server.title;
  277. if (title == nil) {
  278. title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
  279. #if !TARGET_OS_IPHONE
  280. if (title == nil) {
  281. title = [[NSProcessInfo processInfo] processName];
  282. }
  283. #endif
  284. }
  285. NSString* header = server.header;
  286. if (header == nil) {
  287. header = title;
  288. }
  289. NSString* prologue = server.prologue;
  290. if (prologue == nil) {
  291. prologue = [siteBundle localizedStringForKey:@"PROLOGUE" value:@"" table:nil];
  292. }
  293. NSString* epilogue = server.epilogue;
  294. if (epilogue == nil) {
  295. epilogue = [siteBundle localizedStringForKey:@"EPILOGUE" value:@"" table:nil];
  296. }
  297. NSString* footer = server.footer;
  298. if (footer == nil) {
  299. NSString* name = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
  300. NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  301. #if !TARGET_OS_IPHONE
  302. if (!name && !version) {
  303. name = @"OS X";
  304. version = [[NSProcessInfo processInfo] operatingSystemVersionString];
  305. }
  306. #endif
  307. footer = [NSString stringWithFormat:[siteBundle localizedStringForKey:@"FOOTER_FORMAT" value:@"" table:nil], name, version];
  308. }
  309. return [GCDWebServerDataResponse responseWithHTMLTemplate:[siteBundle pathForResource:@"index" ofType:@"html"]
  310. variables:@{
  311. @"device": device,
  312. @"title": title,
  313. @"header": header,
  314. @"prologue": prologue,
  315. @"epilogue": epilogue,
  316. @"footer": footer
  317. }];
  318. }];
  319. // File listing
  320. [self addHandlerForMethod:@"GET" path:@"/list" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  321. return [server listDirectory:request];
  322. }];
  323. // File download
  324. [self addHandlerForMethod:@"GET" path:@"/download" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  325. return [server downloadFile:request];
  326. }];
  327. // File upload
  328. [self addHandlerForMethod:@"POST" path:@"/upload" requestClass:[GCDWebServerMultiPartFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  329. return [server uploadFile:(GCDWebServerMultiPartFormRequest*)request];
  330. }];
  331. // File and folder moving
  332. [self addHandlerForMethod:@"POST" path:@"/move" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  333. return [server moveItem:(GCDWebServerURLEncodedFormRequest*)request];
  334. }];
  335. // File and folder deletion
  336. [self addHandlerForMethod:@"POST" path:@"/delete" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  337. return [server deleteItem:(GCDWebServerURLEncodedFormRequest*)request];
  338. }];
  339. // Directory creation
  340. [self addHandlerForMethod:@"POST" path:@"/create" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
  341. return [server createDirectory:(GCDWebServerURLEncodedFormRequest*)request];
  342. }];
  343. }
  344. return self;
  345. }
  346. #if !__has_feature(objc_arc)
  347. - (void)dealloc {
  348. [_uploadDirectory release];
  349. [_allowedExtensions release];
  350. [_title release];
  351. [_header release];
  352. [_prologue release];
  353. [_epilogue release];
  354. [_footer release];
  355. [super dealloc];
  356. }
  357. #endif
  358. @end
  359. @implementation GCDWebUploader (Subclassing)
  360. - (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath {
  361. return YES;
  362. }
  363. - (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
  364. return YES;
  365. }
  366. - (BOOL)shouldDeleteItemAtPath:(NSString*)path {
  367. return YES;
  368. }
  369. - (BOOL)shouldCreateDirectoryAtPath:(NSString*)path {
  370. return YES;
  371. }
  372. @end