Stream S3 private access Image/video in play framework scala - Issue -


aim:

i have s3 video url , s3 image url. s3 bucket have private access(not public). want stream s3 media files in html.

what tried:

i can access s3 image/video using "access key id" , "secret access key" of "play-s3" plugin.

https://github.com/kaliber/play-s3

by using above plugins can read image/video file content.

code snippet:

controller:

def loads3file(filename: string) = action { implicit request =>         try {             val bucket = s3("user")             val result = bucket.get(filename)             val file = await.result(result, 60 seconds)             val bucketfile(name, contenttype, content, acl, headers) = file             ok.chunked(enumerator(content)).as(contenttype);         }         catch {             case e: exception =>                 badrequest("error: " + e.getmessage)         }     } 

html:

<!doctype html> <html>     <body>         <img width="240" height="320" src="@routes.application.loads3file("user.png")" />         <video controls="controls" preload controls width="320" height="240" name="video name">             <source src="@routes.application.loads3file("user.mov")" type='video/mp4; codecs="avc1.42e01e, mp4a.40.2"' />         </video>     </body> </html> 

what want:

now facing 3 issues.

1) waits whole file read , displayed after that. how play video or show image without waiting whole file download(stream while downloading...)

2) await.result(result, 60 seconds). throws timeout exception after 60 seconds. shouldn't set static time. because each file has own size. takes time stream based on size(bandwidth).

3) image file has been shown after read whole content. video not displaying after read whole content. note: added log , checked. video request called twice. didn't know why :(

can please on proceed further.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -