AbstractPersistor.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const { NotImplementedError } = require('./Errors')
  2. module.exports = class AbstractPersistor {
  3. async sendFile(location, target, source) {
  4. throw new NotImplementedError('method not implemented in persistor', {
  5. method: 'sendFile',
  6. location,
  7. target,
  8. source,
  9. })
  10. }
  11. async sendStream(location, target, sourceStream, opts = {}) {
  12. throw new NotImplementedError('method not implemented in persistor', {
  13. method: 'sendStream',
  14. location,
  15. target,
  16. opts,
  17. })
  18. }
  19. /**
  20. * @param location
  21. * @param name
  22. * @param {Object} opts
  23. * @param {Number} opts.start
  24. * @param {Number} opts.end
  25. * @return {Promise<Readable>}
  26. */
  27. async getObjectStream(location, name, opts) {
  28. throw new NotImplementedError('method not implemented in persistor', {
  29. method: 'getObjectStream',
  30. location,
  31. name,
  32. opts,
  33. })
  34. }
  35. async getRedirectUrl(location, name) {
  36. throw new NotImplementedError('method not implemented in persistor', {
  37. method: 'getRedirectUrl',
  38. location,
  39. name,
  40. })
  41. }
  42. async getObjectSize(location, name) {
  43. throw new NotImplementedError('method not implemented in persistor', {
  44. method: 'getObjectSize',
  45. location,
  46. name,
  47. })
  48. }
  49. async getObjectMd5Hash(location, name) {
  50. throw new NotImplementedError('method not implemented in persistor', {
  51. method: 'getObjectMd5Hash',
  52. location,
  53. name,
  54. })
  55. }
  56. async copyObject(location, fromName, toName) {
  57. throw new NotImplementedError('method not implemented in persistor', {
  58. method: 'copyObject',
  59. location,
  60. fromName,
  61. toName,
  62. })
  63. }
  64. async deleteObject(location, name) {
  65. throw new NotImplementedError('method not implemented in persistor', {
  66. method: 'deleteObject',
  67. location,
  68. name,
  69. })
  70. }
  71. async deleteDirectory(location, name) {
  72. throw new NotImplementedError('method not implemented in persistor', {
  73. method: 'deleteDirectory',
  74. location,
  75. name,
  76. })
  77. }
  78. async checkIfObjectExists(location, name) {
  79. throw new NotImplementedError('method not implemented in persistor', {
  80. method: 'checkIfObjectExists',
  81. location,
  82. name,
  83. })
  84. }
  85. async directorySize(location, name) {
  86. throw new NotImplementedError('method not implemented in persistor', {
  87. method: 'directorySize',
  88. location,
  89. name,
  90. })
  91. }
  92. }