You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fileinfo.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (c) 2015
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function(OC) {
  11. /**
  12. * @class OC.Files.FileInfo
  13. * @classdesc File information
  14. *
  15. * @param {Object} data file data, see attributes for details
  16. *
  17. * @since 8.2
  18. */
  19. var FileInfo = function(data) {
  20. var self = this;
  21. _.each(data, function(value, key) {
  22. if (!_.isFunction(value)) {
  23. self[key] = value;
  24. }
  25. });
  26. if (!_.isUndefined(this.id)) {
  27. this.id = parseInt(data.id, 10);
  28. }
  29. // TODO: normalize path
  30. this.path = data.path || '';
  31. if (this.type === 'dir') {
  32. this.mimetype = 'httpd/unix-directory';
  33. } else {
  34. this.mimetype = this.mimetype || 'application/octet-stream';
  35. }
  36. if (!this.type) {
  37. if (this.mimetype === 'httpd/unix-directory') {
  38. this.type = 'dir';
  39. } else {
  40. this.type = 'file';
  41. }
  42. }
  43. };
  44. /**
  45. * @memberof OC.Files
  46. */
  47. FileInfo.prototype = {
  48. /**
  49. * File id
  50. *
  51. * @type int
  52. */
  53. id: null,
  54. /**
  55. * File name
  56. *
  57. * @type String
  58. */
  59. name: null,
  60. /**
  61. * Path leading to the file, without the file name,
  62. * and with a leading slash.
  63. *
  64. * @type String
  65. */
  66. path: null,
  67. /**
  68. * Mime type
  69. *
  70. * @type String
  71. */
  72. mimetype: null,
  73. /**
  74. * Icon URL.
  75. *
  76. * Can be used to override the mime type icon.
  77. *
  78. * @type String
  79. */
  80. icon: null,
  81. /**
  82. * File type. 'file' for files, 'dir' for directories.
  83. *
  84. * @type String
  85. * @deprecated rely on mimetype instead
  86. */
  87. type: null,
  88. /**
  89. * Permissions.
  90. *
  91. * @see OC#PERMISSION_ALL for permissions
  92. * @type int
  93. */
  94. permissions: null,
  95. /**
  96. * Modification time
  97. *
  98. * @type int
  99. */
  100. mtime: null,
  101. /**
  102. * Etag
  103. *
  104. * @type String
  105. */
  106. etag: null,
  107. /**
  108. * Mount type.
  109. *
  110. * One of null, "external-root", "shared" or "shared-root"
  111. *
  112. * @type string
  113. */
  114. mountType: null,
  115. /**
  116. * @type boolean
  117. */
  118. hasPreview: true,
  119. /**
  120. * @type int
  121. */
  122. sharePermissions: null
  123. };
  124. if (!OC.Files) {
  125. OC.Files = {};
  126. }
  127. OC.Files.FileInfo = FileInfo;
  128. })(OC);