Giter VIP home page Giter VIP logo

Comments (4)

Casper64 avatar Casper64 commented on September 17, 2024 1

For this usecase you can call send_response_to_client and return veb.no_result: https://github.com/vlang/v/blob/master/vlib/veb/README.md#empty-result

If your usecase is sending a file you can also use veb's new ctx.file method
https://github.com/vlang/v/blob/master/vlib/veb/README.md#sending-files

The file method sends the data in a stream towards the browser and will be faster than your current implementation.

pub fn (mut app App) video(mut ctx Context) vweb.Result {
    return ctx.file('path/to/mp4/file')
}

(haven't tested the code)

from v.

wahur666 avatar wahur666 commented on September 17, 2024

For this usecase you can call send_response_to_client and return veb.no_result: https://github.com/vlang/v/blob/master/vlib/veb/README.md#empty-result

If your usecase is sending a file you can also use veb's new ctx.file method https://github.com/vlang/v/blob/master/vlib/veb/README.md#sending-files

The file method sends the data in a stream towards the browser and will be faster than your current implementation.

pub fn (mut app App) video(mut ctx Context) vweb.Result {
    return ctx.file('path/to/mp4/file')
}

(haven't tested the code)

Thank you for the response.

  1. The veb and vweb Result types are not compatible...
  2. If you send file with the following code
pub fn (mut app App) video2() vweb.Result {
    return app.Context.file('path/to/mp4/file')
}

Yes, indeed it is "faster" but the seeking option for the video file not working now...

So thank you, but your answer is not good. On the other hand, I found the workaround this way:

app.Context.send_response_to_client('video/mp4', buf.bytestr())
return vweb.not_found()

from v.

JalonSolov avatar JalonSolov commented on September 17, 2024

vweb is deprecated. veb is the newer web code. The suggestion was for veb, not vweb.

from v.

wahur666 avatar wahur666 commented on September 17, 2024

vweb is deprecated. veb is the newer web code. The suggestion was for veb, not vweb.

I rewrote just this part, to veb and the file still not sent as partial, and not seekable, sorry still not good for me usecase. I will rewrite the rest of it too, but I got my answer. Thank you anyways.

from v.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.