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