cleanup and proxy video data for cloud videos (s3based, amazonS3)

matrix-notifications
Moe 2022-08-07 12:09:28 -07:00
parent b07e3ce400
commit e11edc7c89
2 changed files with 33 additions and 10 deletions

View File

@ -92,9 +92,8 @@ module.exports = function(s,config,lang){
s.group[e.ke].aws_s3.upload({
Bucket: s.group[e.ke].init.aws_s3_bucket,
Key: saveLocation,
Body:fileStream,
ACL:'public-read',
ContentType:'video/'+ext
Body: fileStream,
ContentType: 'video/'+ext
},function(err,data){
if(err){
s.userLog(e,{type:lang['Amazon S3 Upload Error'],msg:err})
@ -114,7 +113,7 @@ module.exports = function(s,config,lang){
}),
size: k.filesize,
end: k.endTime,
href: data.Location
href: ''
}
})
s.setCloudDiskUsedForGroup(e.ke,{
@ -152,6 +151,7 @@ module.exports = function(s,config,lang){
mid: queryInfo.mid,
ke: queryInfo.ke,
time: queryInfo.time,
filename: queryInfo.filename,
details: s.s({
type : 's3',
location : saveLocation
@ -190,6 +190,17 @@ module.exports = function(s,config,lang){
callback()
});
}
function onGetVideoData(video){
const videoDetails = s.parseJSON(video.details)
return new Promise((resolve, reject) => {
const saveLocation = videoDetails.location
var fileStream = s.group[video.ke].aws_s3.getObject({
Bucket: s.group[video.ke].init.aws_s3_bucket,
Key: saveLocation,
}).createReadStream();
resolve(fileStream)
})
}
//amazon s3
s.addCloudUploader({
name: 's3',
@ -201,7 +212,8 @@ module.exports = function(s,config,lang){
beforeAccountSave: beforeAccountSave,
onAccountSave: cloudDiskUseStartup,
onInsertTimelapseFrame: onInsertTimelapseFrame,
onDeleteTimelapseFrameFromCloud: onDeleteTimelapseFrameFromCloud
onDeleteTimelapseFrameFromCloud: onDeleteTimelapseFrameFromCloud,
onGetVideoData
})
//return fields that will appear in settings
return {

View File

@ -114,9 +114,8 @@ module.exports = function(s,config,lang){
s.group[e.ke].whcs.upload({
Bucket: bucketName,
Key: saveLocation,
Body:fileStream,
ACL:'public-read',
ContentType:'video/'+ext
Body: fileStream,
ContentType: 'video/'+ext
},options,function(err,data){
if(err){
console.error(err)
@ -177,7 +176,7 @@ module.exports = function(s,config,lang){
mid: queryInfo.mid,
ke: queryInfo.ke,
time: queryInfo.time,
filename: queryInfo.filename,
filename: queryInfo.filename,
details: s.s({
type : 'whcs',
location : saveLocation
@ -232,6 +231,17 @@ module.exports = function(s,config,lang){
}
return cloudLink
}
function onGetVideoData(video){
const videoDetails = s.parseJSON(video.details)
return new Promise((resolve, reject) => {
const saveLocation = videoDetails.location
var fileStream = s.group[video.ke].whcs.getObject({
Bucket: s.group[video.ke].init.whcs_bucket,
Key: saveLocation,
}).createReadStream();
resolve(fileStream)
})
}
//wasabi
s.addCloudUploader({
name: 'whcs',
@ -243,7 +253,8 @@ module.exports = function(s,config,lang){
beforeAccountSave: beforeAccountSaveForWasabiHotCloudStorage,
onAccountSave: cloudDiskUseStartupForWasabiHotCloudStorage,
onInsertTimelapseFrame: onInsertTimelapseFrame,
onDeleteTimelapseFrameFromCloud: onDeleteTimelapseFrameFromCloud
onDeleteTimelapseFrameFromCloud: onDeleteTimelapseFrameFromCloud,
onGetVideoData
})
return {
"evaluation": "details.use_whcs !== '0'",