Send_data

I want to display a pdf on my browser bu using
send_data(File.read(FILE_PATH + FILE_NAME), :type =>
‘application/pdf’,:disposition => ‘inline’, :filename => FILE_NAME)

But nothing happens. Do you know why ?

On 28 Jun 2010, at 17:56, Mamadou Touré wrote:

I want to display a pdf on my browser bu using
send_data(File.read(FILE_PATH + FILE_NAME), :type =>
‘application/pdf’,:disposition => ‘inline’, :filename => FILE_NAME)

But nothing happens. Do you know why ?

Serving it via AJAX or a normal request? Files always need to be
served as a normal request. Otherwise you should make sure that the
PDF as well as the path is valid.

If it isn’t one of these two, you’ll have to dig in deeper yourself
and provide the list with more information.

Best regards

Peter De Berdt

Peter De Berdt wrote:

On 28 Jun 2010, at 17:56, Mamadou Touré wrote:

I want to display a pdf on my browser bu using
send_data(File.read(FILE_PATH + FILE_NAME), :type =>
‘application/pdf’,:disposition => ‘inline’, :filename => FILE_NAME)

But nothing happens. Do you know why ?

Serving it via AJAX or a normal request? Files always need to be
served as a normal request. Otherwise you should make sure that the
PDF as well as the path is valid.

If it isn’t one of these two, you’ll have to dig in deeper yourself
and provide the list with more information.

Best regards

Peter De Berdt

The path is valid. If I look to my console log I see that it doesn’t
fail. I got this :
Streaming file C:\Users\gen00696\Desktop\Formulaires Intelligents pour
Mamadou\testFIetData.xdp

But noyhing is displayed

On 28 Jun 2010, at 19:28, Mamadou Touré wrote:

served as a normal request. Otherwise you should make sure that the
The path is valid. If I look to my console log I see that it doesn’t
fail. I got this :
Streaming file C:\Users\gen00696\Desktop\Formulaires Intelligents pour
Mamadou\testFIetData.xdp

But noyhing is displayed

It seems to be a common problem with xdp files, which are not PDF
files btw and should not be served as application/pdf, but as
application/vnd.adobe.xdp+xml
But even then, the browser plugins can’t seem to handle it anyway, as
you can see at Adobe forums: Firefox opens application/vnd.adobe.xdp+xml in new... - Adobe Experience League Community - 27562

Best regards

Peter De Berdt

what the hell are u doing, if u have file, u can simplify get link to
user, for it
it will be more faster than use rails, and more native for user
Best Regards, dieinzige

On 28 Jun, 2010,at 03:56 PM, Mamadou Touré [email protected] wrote:

I want to display a pdf on my browser bu using
send_data(File.read(FILE_PATH + FILE_NAME), :type =>
‘application/pdf’,:disposition => ‘inline’, :filename => FILE_NAME)

But nothing happens. Do you know why ?

Posted via http://www.ruby-forum.com/.


You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Michael P. wrote:

On 28 June 2010 21:45, dieinzige [email protected] wrote:

what the hell are u doing, if u have file, u can simplify get link to user,

What if the OP needs users to be logged in to view files? Or complete
some other approval process. Not much sense having them accessible
from the public directory in that instance, which would allow people
to just bypass the security.

I’m having the file displayed now, but the other issue that I’m facing
now is : I have several files to open, I put them in an array that I
loop through, but only the last file is opened:

What’s wrong ?

arr.each do |form|
file_name = form + “-” + vue.inte_no.to_s + “-” + vue.poas_id.to_s

  • “-” + vue.prch_id.to_s + “.xdp”
    send_file(path_pdf_cpy + file_name,:type => ‘application/pdf’ ,
    :disposition => ‘attachment’, :filename => file_name)
    end

On 28 June 2010 21:45, dieinzige [email protected] wrote:

what the hell are u doing, if u have file, u can simplify get link to user,

What if the OP needs users to be logged in to view files? Or complete
some other approval process. Not much sense having them accessible
from the public directory in that instance, which would allow people
to just bypass the security.

Mamadou Touré wrote:
[…]

I’m having the file displayed now, but the other issue that I’m facing
now is : I have several files to open, I put them in an array that I
loop through, but only the last file is opened:

What’s wrong ?

arr.each do |form|
file_name = form + “-” + vue.inte_no.to_s + “-” + vue.poas_id.to_s

  • “-” + vue.prch_id.to_s + “.xdp”
    send_file(path_pdf_cpy + file_name,:type => ‘application/pdf’ ,
    :disposition => ‘attachment’, :filename => file_name)
    end

You can’t send multiple files in response to one request. Do you want
to join the pages of the PDF files into one long file?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Mamadou Touré wrote:
[…]

Thanks Marnen,

Unfortunately I have to hav each file on its own, I must not merge them
in on single file. Is there a way to simulate several requests in order
to loop through the array ?

Even if there were, the browser would not be able to understand it. You
could use several Ajax requests, but if I were your user, I’d be annoyed
that your website was randomly downloading files without my consent.
Why can’t you just provide several download links for the files? Or
create a zip or tar archive?

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Jeremy wrote:

Hi everyone,
I have to say that I am very pleased that I have received such great
responses! Â I kept expecting that I would get the cold shoulder but
instead I got real answers. I feel I have a solid direction and don’t
feel like I’m blindly trying to figure this stuff out. So please
accept my sincerest thank you to all of you for helping me out!
Â
Bob,
I decided to go ahead and buy the book regardless if it’s
outdated :slight_smile: Â I kinda figured the way deployment is done couldn’t have
changed too much.
Â
It probably has. Â I don’t think Passenger was in wide use at the time,
and it’s now probably the most common choice for deployment.
Â
Peter,
Thank you, I appreciate your contribution as well. Â Although, it was a
little over my head when you started talking “mercurial repositories”
but I’m sure I’ll understand what that means sometime in the near
future.

Mercurial is a version control system – though it’s not in all that
wide use in the Rails community. Â I think most Rails developers use Git.
 Which version control system are you using?

(Hint: if the answer is “none”, fix that today by installing Git.
 There is no excuse whatsoever for neglecting version control.)

Also, check out Heroku for very easy Rails deployment.Â

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Mamadou Touré wrote:
[…]

Thanks Marnen,

Unfortunately I have to hav each file on its own, I must not merge them
in on single file. Is there a way to simulate several requests in order
to loop through the array ?

Even if there were, the browser would not be able to understand it. You
could use several Ajax requests, but if I were your user, I’d be annoyed
that your website was randomly downloading files without my consent.
Why can’t you just provide several download links for the files? Or
create a zip or tar archive?

Marnen Laibow-Koser wrote:

Mamadou Touré wrote:
[…]

Thanks Marnen,

Unfortunately I have to hav each file on its own, I must not merge them
in on single file. Is there a way to simulate several requests in order
to loop through the array ?

Even if there were, the browser would not be able to understand it. You
could use several Ajax requests, but if I were your user, I’d be annoyed
that your website was randomly downloading files without my consent.
Why can’t you just provide several download links for the files? Or
create a zip or tar archive?

So is there another way to merge my xdp file to my pdf without opening
it in a browser (ie without using the send_file instruction) ? if so,
this would solve my problem

Marnen Laibow-Koser wrote:

Mamadou Touré wrote:
[…]

I’m having the file displayed now, but the other issue that I’m facing
now is : I have several files to open, I put them in an array that I
loop through, but only the last file is opened:

What’s wrong ?

arr.each do |form|
file_name = form + “-” + vue.inte_no.to_s + “-” + vue.poas_id.to_s

  • “-” + vue.prch_id.to_s + “.xdp”
    send_file(path_pdf_cpy + file_name,:type => ‘application/pdf’ ,
    :disposition => ‘attachment’, :filename => file_name)
    end

You can’t send multiple files in response to one request. Do you want
to join the pages of the PDF files into one long file?

Best,

Thanks Marnen,

Unfortunately I have to hav each file on its own, I must not merge them
in on single file. Is there a way to simulate several requests in order
to loop through the array ?

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Peter De Berdt wrote:

On 30 Jun 2010, at 18:13, Mamadou Touré wrote:

that your website was randomly downloading files without my consent.
Why can’t you just provide several download links for the files? Or
create a zip or tar archive?

So is there another way to merge my xdp file to my pdf without opening
it in a browser (ie without using the send_file instruction) ? if so,
this would solve my problem

Find a command line utility for your server OS that will do that for
you: command line pdf xdp - Google Search

Then just run the necessary command line instruction from your Rails
app.

Best regards

Peter De Berdt

I don’t even find a command line utility that merge and xdp with a pdf
:frowning:

On 30 Jun 2010, at 18:13, Mamadou Touré wrote:

that your website was randomly downloading files without my consent.
Why can’t you just provide several download links for the files? Or
create a zip or tar archive?

So is there another way to merge my xdp file to my pdf without opening
it in a browser (ie without using the send_file instruction) ? if so,
this would solve my problem

Find a command line utility for your server OS that will do that for
you: command line pdf xdp - Google Search

Then just run the necessary command line instruction from your Rails
app.

Best regards

Peter De Berdt