4

Is it possible to stream audio-file from BlobStore on AppEngine in general?
And if yes, what about streaming .mp3 file from direct url?

2 Answers 2

5

Yep!! This is my implementation:

public class Serve extends HttpServlet {

    private static final long serialVersionUID = 5603629129606331547L;

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
        BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
        BlobstoreServiceFactory.getBlobstoreService().serve(blobKey, res);
    }
}

.. and this is the web.xml:

<servlet>
        <servlet-name>Serve</servlet-name>
        <servlet-class><my-package>.Serve</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Serve</servlet-name>
        <url-pattern>/serve</url-pattern>
    </servlet-mapping>

pay attention that "direct url" (getServingUrl I think you mean) exists only for images: https://developers.google.com/appengine/docs/java/images/overview#Transforming_Images_from_the_Blobstore

10
  • 2
    Except that this is not streaming. It's just a file download. May 7, 2012 at 17:05
  • uhm.. @PeterKnego you are right: here is the right class for streaming developers.google.com/appengine/docs/java/javadoc/com/google/… May 8, 2012 at 8:35
  • 2
    Sorry, but no. Streaming means that you deliver data as needed, e.g. as user views/listens to the media. Download means that you send the data as fast as possible and client caches it. App Engine limits requests to 30s, so you can not do streaming. May 8, 2012 at 17:22
  • 1
    @PeterKnego The only difference between streaming and downloading is how the data's consumed; clients can control that by reading data only as they need it. App Engine's execution limit applies only to code execution time, not to the time taken to upload or download data, so this solution works just fine. May 17, 2012 at 1:27
  • @Nick - actually difference is in how data is served. In true streaming (RTSP, RTMP) client will notify server of stream consumption and server will accordingly send more/less data. So connection is all the time open and there needs to be code on server acting on client signals. May 17, 2012 at 16:14
0

In general the answer is no:

https://cloud.google.com/appengine/docs/standard/go/how-requests-are-handled#streaming_responses

As others have indicated you could chunk up your data to limit the "cost" and then have your client control when to get the next chunk.

A better solution Use Cloud Run instead:

https://cloud.google.com/blog/products/serverless/cloud-run-now-supports-http-grpc-server-streaming

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.