Questions tagged [sendfile]

sendfile is the general function representation of sending data/file over the network. The network may be raw tcp sockets or any other connection itself. This tag should be used for querying about such file sending methods defined in different web/(android etc.) frameworks

279 questions
88
votes
2 answers

What is the difference between send_data and send_file in Ruby on Rails?

Which one is best for streaming and file downloads? Please provide examples.
Mr. Black
  • 11,692
  • 13
  • 60
  • 85
39
votes
1 answer

express: how to send html together with css using sendFile?

var app = require('express')(); app.get('/', function(req, res) { res.sendFile(__dirname + "/" + "index.html"); }); I used the above Node.js code to send a html file. To get the html file formatted I…
neolicd
  • 1,009
  • 2
  • 11
  • 14
31
votes
4 answers

RSpec send_file testing

How to test a controller action that sends a file? If I do it with controller.should_receive(:send_file) test fails with "Missing template" because nothing gets rendered.
Mirko
  • 5,207
  • 2
  • 37
  • 33
25
votes
1 answer

How to send header in flask send_file?

The problem is I am unable to send headers when using send_file, is there any workaround for this? I want to be able to send headers when sending files to client. return send_file(mp3_filepath, 'audio/mpeg')
Alireza
  • 6,497
  • 13
  • 59
  • 132
21
votes
3 answers

C, sendfile() and send() difference?

sendfile() copies data between two file descripters within kernel space. Somewhere I saw if you are writing a web server in C in linux you should use send() and recv() instead of using write() and read(). So is the send() use the kernel space as…
samsamara
  • 4,630
  • 7
  • 36
  • 66
18
votes
4 answers

NodeJS sendFile with File Name in download

I try to send file to client with this code: router.get('/get/myfile', function (req, res, next) { res.sendFile("/other_file_name.dat"); }); it's work fine but I need that when user download this file from the…
Massimo Caroccia
  • 417
  • 2
  • 6
  • 14
17
votes
5 answers

c send and receive file

This is the server (sendfile) part: offset = 0; for (size_to_send = fsize; size_to_send > 0; ){ rc = sendfile(newsockd, fd, &offset, size_to_send); if (rc <= 0){ perror("sendfile"); onexit(newsockd, sockd, fd, 3); } offset += rc; …
polslinux
  • 1,739
  • 9
  • 34
  • 73
15
votes
5 answers

send_file just sends an empty file

Im looking for a way to download a xml file. I use: file_path = 'folder/' + xml_name + '.xml' send_file file_path, :type => "text/xml" but this always downloads me an empty file. The file itself has 16 KB of data in it... why is that? Maechi
Markus
  • 3,948
  • 8
  • 48
  • 64
14
votes
3 answers

Send file from client to server using XMLRPC?

I want to write Python code to send a file from client to server. server needs to save the file sent from the client. But my code have some bugs which I cannot fix. Below is my server code: # server.py from SimpleXMLRPCServer import…
user311703
  • 1,113
  • 2
  • 14
  • 25
14
votes
1 answer

Understanding sendfile() and splice()

sendfile() can be used to transmit data from a "file" descriptor to a "socket" descriptor in order to get data from machine A to machine B. Is it possible to get the data at the receiving end from the "socket" descriptor to a file with similar…
user880946
  • 429
  • 1
  • 5
  • 5
11
votes
4 answers

rails media file stream accept byte range request through send_data or send_file method

I have the following problem. Sounds are hidden from the public folder, cause there are only certain Users who should have access to the sound files. So I made a certain method, which acts like a sound url, but calculates first, whether the current…
Markus
  • 3,948
  • 8
  • 48
  • 64
11
votes
2 answers

swift, send file to server

I am learning swift and I send a request to the server with the code below. It works for simple request and I get response from the server. My problem is I can not send a file to server. code : let parameters = parameter let request =…
m-jamshidzadeh
  • 121
  • 2
  • 6
11
votes
2 answers

Minimizing copies when writing large data to a socket

I am writing an application server that processes images (large data). I am trying to minimize copies when sending image data back to clients. The processed images I need to send to clients are in buffers obtained from jemalloc. The ways I have…
Rajiv
  • 2,587
  • 2
  • 22
  • 33
10
votes
3 answers

expressjs: Sending a file from parent directory

I would like to use expressjs's sendfile to send a file from a parent directory of the script file. What I tried to do is this: app.get('/', function(req, res){ res.sendfile('../../index.html'); }); I get a forbidden error because apparently,…
Silvester
  • 496
  • 1
  • 3
  • 14
9
votes
3 answers

Message "X-Accel-Mapping header missing" in Nginx error log

I am running a Rails 3 site on Ubuntu 8.04 with Nginx 1.0.0 and Passenger 3.0.7. In my Nginx error.log I started seeing the message X-Accel-Mapping header missing quite a lot. Googling lead me to the docs of Rack::Sendfile and to the Nginx…
Manuel Meurer
  • 3,238
  • 6
  • 35
  • 50
1
2 3
18 19