2018-07-27 09:58:00 -07:00
|
|
|
const getMediaDimensions = require('../../utils/getMediaDimensions.js');
|
2018-07-26 13:48:53 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
async function createFileRecordDataAfterGet(resolveResult, getResult) {
|
|
|
|
const { name, claimId, outpoint, contentType: fileType } = resolveResult;
|
2018-07-26 17:57:26 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
const { file_name: fileName, download_path: filePath } = getResult;
|
2018-07-26 17:57:26 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath);
|
2018-07-26 17:57:26 -07:00
|
|
|
|
2018-07-26 13:48:53 -07:00
|
|
|
return {
|
|
|
|
name,
|
|
|
|
claimId,
|
|
|
|
outpoint,
|
|
|
|
fileHeight,
|
|
|
|
fileWidth,
|
|
|
|
fileName,
|
|
|
|
filePath,
|
|
|
|
fileType,
|
|
|
|
};
|
2018-10-04 10:26:42 -04:00
|
|
|
}
|
2018-07-26 13:48:53 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
async function createFileRecordDataAfterPublish(
|
|
|
|
fileName,
|
|
|
|
fileType,
|
|
|
|
publishParams,
|
|
|
|
publishResultsOutput
|
|
|
|
) {
|
|
|
|
const { name, file_path: filePath } = publishParams;
|
2018-07-26 17:57:26 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
const { claim_id: claimId, txid, nout } = publishResultsOutput;
|
2018-07-26 17:57:26 -07:00
|
|
|
|
2019-05-24 16:39:46 -04:00
|
|
|
const { height: fileHeight, width: fileWidth } = await getMediaDimensions(fileType, filePath);
|
2018-07-26 13:48:53 -07:00
|
|
|
|
2018-11-08 14:05:06 -05:00
|
|
|
return {
|
2018-07-26 13:48:53 -07:00
|
|
|
name,
|
|
|
|
claimId,
|
|
|
|
outpoint: `${txid}:${nout}`,
|
|
|
|
fileHeight,
|
|
|
|
fileWidth,
|
|
|
|
fileName,
|
|
|
|
filePath,
|
|
|
|
fileType,
|
|
|
|
};
|
2018-07-26 18:40:46 -07:00
|
|
|
}
|
2018-07-26 13:48:53 -07:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
createFileRecordDataAfterGet,
|
|
|
|
createFileRecordDataAfterPublish,
|
|
|
|
};
|