2018-07-27 09:58:00 -07:00
|
|
|
const getMediaDimensions = require('../../utils/getMediaDimensions.js');
|
2018-07-26 13:48:53 -07:00
|
|
|
|
2018-07-26 18:40:46 -07:00
|
|
|
async function createFileRecordDataAfterGet (resolveResult, getResult) {
|
2018-07-26 17:57:26 -07:00
|
|
|
const {
|
|
|
|
name,
|
|
|
|
claimId,
|
|
|
|
outpoint,
|
|
|
|
contentType: fileType,
|
|
|
|
} = resolveResult;
|
|
|
|
|
|
|
|
const {
|
|
|
|
file_name: fileName,
|
|
|
|
download_path: filePath,
|
|
|
|
} = getResult;
|
|
|
|
|
|
|
|
const {
|
|
|
|
height: fileHeight,
|
|
|
|
width: fileWidth,
|
2018-07-27 09:58:00 -07:00
|
|
|
} = 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
|
|
|
|
2018-07-26 18:40:46 -07:00
|
|
|
async function createFileRecordDataAfterPublish (fileName, fileType, publishParams, publishResults) {
|
2018-07-26 17:57:26 -07:00
|
|
|
const {
|
|
|
|
name,
|
|
|
|
file_path: filePath,
|
|
|
|
} = publishParams;
|
|
|
|
|
|
|
|
const {
|
|
|
|
claim_id: claimId,
|
|
|
|
txid,
|
|
|
|
nout,
|
|
|
|
} = publishResults;
|
|
|
|
|
2018-07-26 18:40:46 -07:00
|
|
|
const {
|
|
|
|
height: fileHeight,
|
|
|
|
width: fileWidth,
|
2018-07-27 09:58:00 -07:00
|
|
|
} = 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,
|
|
|
|
};
|