GCDWebUploader.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "GCDWebServer.h"
  26. @class GCDWebUploader;
  27. @protocol GCDWebUploaderDelegate <NSObject>
  28. @optional
  29. - (void)webUploader:(GCDWebUploader*)uploader didDownloadFileAtPath:(NSString*)path;
  30. - (void)webUploader:(GCDWebUploader*)uploader didUploadFileAtPath:(NSString*)path;
  31. - (void)webUploader:(GCDWebUploader*)uploader didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath;
  32. - (void)webUploader:(GCDWebUploader*)uploader didDeleteItemAtPath:(NSString*)path;
  33. - (void)webUploader:(GCDWebUploader*)uploader didCreateDirectoryAtPath:(NSString*)path;
  34. @end
  35. @interface GCDWebUploader : GCDWebServer
  36. @property(nonatomic, readonly) NSString* uploadDirectory;
  37. @property(nonatomic, assign) id<GCDWebUploaderDelegate> delegate;
  38. @property(nonatomic, copy) NSArray* allowedFileExtensions; // Default is nil i.e. all file extensions are allowed
  39. @property(nonatomic) BOOL showHiddenFiles; // Default is NO
  40. @property(nonatomic, copy) NSString* title; // Default is application name (must be HTML escaped)
  41. @property(nonatomic, copy) NSString* header; // Default is same as title (must be HTML escaped)
  42. @property(nonatomic, copy) NSString* prologue; // Default is mini help (must be raw HTML)
  43. @property(nonatomic, copy) NSString* epilogue; // Default is nothing (must be raw HTML)
  44. @property(nonatomic, copy) NSString* footer; // Default is application name and version (must be HTML escaped)
  45. - (instancetype)initWithUploadDirectory:(NSString*)path;
  46. @end
  47. @interface GCDWebUploader (Subclassing)
  48. - (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath; // Default implementation returns YES
  49. - (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath; // Default implementation returns YES
  50. - (BOOL)shouldDeleteItemAtPath:(NSString*)path; // Default implementation returns YES
  51. - (BOOL)shouldCreateDirectoryAtPath:(NSString*)path; // Default implementation returns YES
  52. @end