2018-03-03 02:02:07 +01:00
|
|
|
export const createPublishMetadata = (claim, { type }, { title, description, license, nsfw }, publishInChannel, selectedChannel) => {
|
2018-03-01 23:00:29 +01:00
|
|
|
let metadata = {
|
|
|
|
name: claim,
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
license,
|
|
|
|
nsfw,
|
|
|
|
type,
|
|
|
|
};
|
|
|
|
if (publishInChannel) {
|
|
|
|
metadata['channelName'] = selectedChannel;
|
|
|
|
}
|
|
|
|
return metadata;
|
|
|
|
};
|
|
|
|
|
2018-03-03 02:24:18 +01:00
|
|
|
export const createPublishFormData = (file, thumbnail, metadata) => {
|
2018-03-01 23:00:29 +01:00
|
|
|
let fd = new FormData();
|
|
|
|
// append file
|
|
|
|
fd.append('file', file);
|
2018-03-03 02:24:18 +01:00
|
|
|
// append thumbnail
|
|
|
|
if (thumbnail) {
|
|
|
|
fd.append('thumbnail', thumbnail);
|
|
|
|
}
|
2018-03-01 23:00:29 +01:00
|
|
|
// append metadata
|
|
|
|
for (let key in metadata) {
|
|
|
|
if (metadata.hasOwnProperty(key)) {
|
|
|
|
fd.append(key, metadata[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fd;
|
|
|
|
};
|
2018-03-03 02:02:07 +01:00
|
|
|
|
|
|
|
export const createThumbnailUrl = (channel, channelId, claim, host) => {
|
|
|
|
return `${host}/${channel}:${channelId}/${claim}-thumb.png`;
|
|
|
|
};
|