import * as cloud from "@pulumi/cloud-azure" ; const bucket = new cloud . Bucket ( "bucket" ) ; const ffmpegThumbnailTask = new cloud . Task ( "ffmpegThumbTask" , { build : "./docker-ffmpeg-thumb" , } ) ; bucket . onPut ( "onNewVideo" , async ( bucketArgs ) => { console . log ( `*** New video: file ${ bucketArgs . key } was uploaded at ${ bucketArgs . eventTime }.` ) ; const fullPath = bucketArgs . key ; const slashIndex = fullPath . indexOf ( "/" ) ; const container = fullPath . substr ( 0 , slashIndex ) ; const file = fullPath . substr ( slashIndex + 1 ) ; const thumbnailFile = file . substring ( 0 , file . indexOf ( "_" ) ) + ".jpg" ; const framePos = file . substring ( file . indexOf ( "_" ) + 1 , file . indexOf ( "." ) ) . replace ( "-" , ":" ) ; const env = { "AZURE_STORAGE_CONNECTION_STRING" : bucket . storageAccount . primaryBlobConnectionString . get ( ) , "CONTAINER" : container , "INPUT_VIDEO" : file , "TIME_OFFSET" : framePos , "OUTPUT_FILE" : thumbnailFile , } ; await ffmpegThumbnailTask . run ( { environment : env , } ) ; console . log ( `Finished thumbnailer task.` ) ; } , { keySuffix : ".mp4" } ) ; bucket . onPut ( "onNewThumbnail" , bucketArgs => { console . log ( `*** New thumbnail: file ${ bucketArgs . key } was saved at ${ bucketArgs . eventTime }.` ) ; return Promise . resolve ( ) ; } , { keySuffix : ".jpg" } ) ; export const bucketName = bucket . container . id ;