AbstractPersistor.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const { NotImplementedError } = require('./Errors')
  2. module.exports = class AbstractPersistor {
  3. /**
  4. * @param location
  5. * @param target
  6. * @param {string} source
  7. * @return {Promise<void>}
  8. */
  9. async sendFile(location, target, source) {
  10. throw new NotImplementedError('method not implemented in persistor', {
  11. method: 'sendFile',
  12. location,
  13. target,
  14. source,
  15. })
  16. }
  17. /**
  18. * @param location
  19. * @param target
  20. * @param {NodeJS.ReadableStream} sourceStream
  21. * @param {Object} opts
  22. * @return {Promise<void>}
  23. */
  24. async sendStream(location, target, sourceStream, opts = {}) {
  25. throw new NotImplementedError('method not implemented in persistor', {
  26. method: 'sendStream',
  27. location,
  28. target,
  29. opts,
  30. })
  31. }
  32. /**
  33. * @param location
  34. * @param name
  35. * @param {Object} [opts]
  36. * @param {Number} [opts.start]
  37. * @param {Number} [opts.end]
  38. * @return {Promise<NodeJS.ReadableStream>}
  39. */
  40. async getObjectStream(location, name, opts = {}) {
  41. throw new NotImplementedError('method not implemented in persistor', {
  42. method: 'getObjectStream',
  43. location,
  44. name,
  45. opts,
  46. })
  47. }
  48. /**
  49. * @param {string} location
  50. * @param {string} name
  51. * @return {Promise<string>}
  52. */
  53. async getRedirectUrl(location, name) {
  54. throw new NotImplementedError('method not implemented in persistor', {
  55. method: 'getRedirectUrl',
  56. location,
  57. name,
  58. })
  59. }
  60. /**
  61. * @param {string} location
  62. * @param {string} name
  63. * @param {Object} opts
  64. * @return {Promise<number>}
  65. */
  66. async getObjectSize(location, name, opts) {
  67. throw new NotImplementedError('method not implemented in persistor', {
  68. method: 'getObjectSize',
  69. location,
  70. name,
  71. })
  72. }
  73. /**
  74. * @param {string} location
  75. * @param {string} name
  76. * @param {Object} opts
  77. * @return {Promise<string>}
  78. */
  79. async getObjectMd5Hash(location, name, opts) {
  80. throw new NotImplementedError('method not implemented in persistor', {
  81. method: 'getObjectMd5Hash',
  82. location,
  83. name,
  84. })
  85. }
  86. /**
  87. * @param {string} location
  88. * @param {string} fromName
  89. * @param {string} toName
  90. * @param {Object} opts
  91. * @return {Promise<void>}
  92. */
  93. async copyObject(location, fromName, toName, opts) {
  94. throw new NotImplementedError('method not implemented in persistor', {
  95. method: 'copyObject',
  96. location,
  97. fromName,
  98. toName,
  99. })
  100. }
  101. /**
  102. * @param {string} location
  103. * @param {string} name
  104. * @return {Promise<void>}
  105. */
  106. async deleteObject(location, name) {
  107. throw new NotImplementedError('method not implemented in persistor', {
  108. method: 'deleteObject',
  109. location,
  110. name,
  111. })
  112. }
  113. /**
  114. * @param {string} location
  115. * @param {string} name
  116. * @param {string} [continuationToken]
  117. * @return {Promise<void>}
  118. */
  119. async deleteDirectory(location, name, continuationToken) {
  120. throw new NotImplementedError('method not implemented in persistor', {
  121. method: 'deleteDirectory',
  122. location,
  123. name,
  124. })
  125. }
  126. /**
  127. * @param {string} location
  128. * @param {string} name
  129. * @param {Object} opts
  130. * @return {Promise<boolean>}
  131. */
  132. async checkIfObjectExists(location, name, opts) {
  133. throw new NotImplementedError('method not implemented in persistor', {
  134. method: 'checkIfObjectExists',
  135. location,
  136. name,
  137. })
  138. }
  139. /**
  140. * @param {string} location
  141. * @param {string} name
  142. * @param {string} [continuationToken]
  143. * @return {Promise<number>}
  144. */
  145. async directorySize(location, name, continuationToken) {
  146. throw new NotImplementedError('method not implemented in persistor', {
  147. method: 'directorySize',
  148. location,
  149. name,
  150. })
  151. }
  152. }