GCDWebDAVServer.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 GCDWebDAVServer;
  27. // These methods are always called on main thread
  28. @protocol GCDWebDAVServerDelegate <GCDWebServerDelegate>
  29. @optional
  30. - (void)davServer:(GCDWebDAVServer*)server didDownloadFileAtPath:(NSString*)path;
  31. - (void)davServer:(GCDWebDAVServer*)server didUploadFileAtPath:(NSString*)path;
  32. - (void)davServer:(GCDWebDAVServer*)server didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath;
  33. - (void)davServer:(GCDWebDAVServer*)server didCopyItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath;
  34. - (void)davServer:(GCDWebDAVServer*)server didDeleteItemAtPath:(NSString*)path;
  35. - (void)davServer:(GCDWebDAVServer*)server didCreateDirectoryAtPath:(NSString*)path;
  36. @end
  37. @interface GCDWebDAVServer : GCDWebServer
  38. @property(nonatomic, readonly) NSString* uploadDirectory;
  39. @property(nonatomic, assign) id<GCDWebDAVServerDelegate> delegate;
  40. @property(nonatomic, copy) NSArray* allowedFileExtensions; // Default is nil i.e. all file extensions are allowed
  41. @property(nonatomic) BOOL showHiddenFiles; // Default is NO
  42. - (instancetype)initWithUploadDirectory:(NSString*)path;
  43. @end
  44. // These methods can be called from any thread
  45. @interface GCDWebDAVServer (Subclassing)
  46. - (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath; // Default implementation returns YES
  47. - (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath; // Default implementation returns YES
  48. - (BOOL)shouldCopyItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath; // Default implementation returns YES
  49. - (BOOL)shouldDeleteItemAtPath:(NSString*)path; // Default implementation returns YES
  50. - (BOOL)shouldCreateDirectoryAtPath:(NSString*)path; // Default implementation returns YES
  51. @end