Constructor
new BagItFile(absSourcePath, relDestPath, stats)
Parameters:
Name | Type | Description |
---|---|---|
absSourcePath |
string |
The absolute source path of the file. The bagger will copy the file from this path into relDestPath inside the bag. |
relDestPath |
string |
The relative path at which this file should reside within the bag. For manifests, relDestPath will be inside the top-level directory of the bag. For example, at 'manifest-sha256.txt'. For payload files, relDestPath will have the prefix 'data/'. For example, 'data/images/photo.jpg.' Some bagging profiles permit tag files in subdirectories outside the payload directory; hence 'dpn-data/dpn-tags.txt' may be a valid relDestPath. BagItFile infers the type of the file from the relDestPath param. |
stats |
object |
A subset of stats gathered from Node's fs.Stat() function. The BagItFile object keeps only a handful of properties from fs.Stat(). This param can be a Node.js fs.Stats object or a FileStat object. |
- Source:
Members
absSourcePath :string
absSourcePath is the absolute source path to this file. The bagger will copy the file from this path into relDestPath inside the bag.
- Source:
checksums :Object.<string, string>
checksums contains a hash of fixity values we calculate on the file's contents.
key = algorithm name ('md5', 'sha256', etc.) value = digest
- Source:
fileType :string
fileType is one of 'manifest', 'tagmanifest', 'payload', or 'tagfile', based on relDestPath. File types are defined in Constants.FILE_TYPES.
- Source:
gid :number
gid is the id of the group that owns this file.
- Source:
isDirectory :boolean
isDirectory will be true if this is a directory.
- Source:
isFile :boolean
isFile will be true if this is a regular file. It will be false if this is a directory, socket, or link.
- Source:
keyValueCollection :KeyValueCollection
keyValueCollection is used by the validator to store the parsed contents of tag files and manifests.
- Source:
mtime :Date
mtime is the time this file was last modified.
- Source:
relDestPath :string
The relative path at which this file should reside within the bag. For manifests, relDestPath will be inside the top-level directory of the bag. For example, at 'manifest-sha256.txt'. For payload files, relDestPath will have the prefix 'data/'. For example, 'data/images/photo.jpg.' Some bagging profiles permit tag files in subdirectories outside the payload directory; hence 'dpn-data/dpn-tags.txt' may be a valid relDestPath. BagItFile infers the type of the file from the relDestPath param.
- Source:
size :number
size is the size, in bytes, of the file.
- Source:
uid :number
uid is the id of the user who owns the file.
- Source:
Methods
(static) getFileType(relDestPath) → {string}
getFileType returns the type of BagIt file based on relDestPath. File types are defined in Constants.FILE_TYPES and include 'manifest', 'tagmanifest', 'payload', and 'tagfile'.
Parameters:
Name | Type | Description |
---|---|---|
relDestPath |
string |
The relative path, within the bag, of the file. For example, 'data/images/photo.jpg' or 'manifest-sha256.txt'. |
- Source:
getCryptoHash(algorithm, done)
This returns a crypto hash that will add a hex digest to this BagItFile's checksums object upon completion. For example, adding a crypto hash with algorithm 'sha512' will result in bagItFile.checksums['sha512'] being populated with the file's sha512 digest after you pipe the file's contents through the hash object. It's up to the caller to pipe the data through.
Parameters:
Name | Type | Description |
---|---|---|
algorithm |
string |
The hash digest algorithm to calculate. For example, 'md5', 'sha256', 'sha512', etc. |
done |
function |
A callback to call when hasing is complete. The callback will be given data with the format: |
- Source:
Example
{ absSourcePath: <bagItFile.absSourcePath>,
relPath: <bagItFile.relDestPath>,
algorithm: <hashing algorithm>,
digest: <message digest as hex string>
}
getManifestEntry(algorithm) → {string}
Returns the manifest entry for the specified algorithm, or throws an exception if the checksum for that algorithm is not present. The format of the returned string is suitable for printing into a payload manifest or tag manifest.
Parameters:
Name | Type | Description |
---|---|---|
algorithm |
string |
The algorithm of the digest to retrieve. |
- Source:
isPayloadFile() → {boolean}
Returns true if this is a payload file.
- Source:
isPayloadManifest() → {boolean}
Returns true if this is a payload manifest.
- Source:
isTagFile() → {boolean}
Returns true if this is a tag file.
- Source:
isTagManifest() → {boolean}
Returns true if this is a tag manifest.
- Source: