FileService.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * FileService.js
  3. *
  4. * @author realor
  5. */
  6. import { Service } from './Service.js'
  7. class FileService extends Service {
  8. constructor(name, description = null, url = null, username = null, password = null) {
  9. super(name, description, url, username, password)
  10. }
  11. open(path, readyCallback, progressCallback) {
  12. readyCallback(new Result(Result.ERROR, 'Not implemented.'))
  13. }
  14. save(path, data, readyCallback, progressCallback) {
  15. readyCallback(new Result(Result.ERROR, 'Not implemented.'))
  16. }
  17. remove(path, readyCallback, progressCallback) {
  18. readyCallback(new Result(Result.ERROR, 'Not implemented.'))
  19. }
  20. makeCollection(path, readyCallback, progressCallback) {
  21. readyCallback(new Result(Result.ERROR, 'Not implemented.'))
  22. }
  23. }
  24. class Result {
  25. static OK = 0
  26. static ERROR = 1 // unknown error
  27. static INVALID_CREDENTIALS = 2
  28. static FORBIDDEN = 3
  29. constructor(status, message, path, metadata, entries, data) {
  30. this.status = status
  31. this.message = message
  32. this.path = path
  33. this.metadata = metadata
  34. this.entries = entries // Metadata
  35. this.data = data // file data
  36. }
  37. }
  38. class Metadata {
  39. static COLLECTION = 1
  40. static FILE = 2
  41. constructor(name, description, type, size = 0, lastModified = 0) {
  42. this.name = name
  43. this.description = description
  44. this.type = type
  45. this.size = size
  46. this.lastModified = lastModified
  47. }
  48. }
  49. export { FileService, Result, Metadata }