Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Response.WriteFile question

Reply
Thread Tools

Response.WriteFile question

 
 
enzeez
Guest
Posts: n/a
 
      04-03-2008
Hello,

I have a record stored in sqlserver database in binary form.
I want to display a link that will allow user to download this record as
a File.

I want to create a file at runtime or pass a specified number of bytes
to user's browser. I provide a link to the user and when he clicks the
link i want a file dialog to appear and the user can then give a file
name to store those bytes as a file.

The problem is i need to create links dynamically and supply the binary
or image bytes as a file download to user. How can i do this?

Can someone help me out here?

Thanks in advance
enzeez
 
Reply With Quote
 
 
 
 
Augustin Prasanna
Guest
Posts: n/a
 
      04-03-2008
I am sure your table will have a primary key and you will be using the
primary key to fetch the content

1) Link to some page like download.aspx and pass the key value (e.g. <a
href="download.aspx?fileid=1234">download</a>)
2) In download.aspx codebehind, write code to retrieve the content for this
Id
3) Write the resultset to using Response.binarywrite

below is a asp code snippet which almost does the same.

response.clear
response.contentType = "application/octet-stream"
response.addheader "content-disposition", "attachment; filename=" & FileName
set stream = server.CreateObject("ADODB.Stream")
stream.type = adTypeBinary
stream.open
stream.LoadFromFile Server.MapPath("/files") & FileName
while not stream.EOS
response.BinaryWrite Stream.Read(1024 * 64)
wend
stream.Close
Set stream = Nothing
response.Flush
response.End


Regards,
Augustin Prasanna

"enzeez" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> Hello,
>
> I have a record stored in sqlserver database in binary form.
> I want to display a link that will allow user to download this record as a
> File.
>
> I want to create a file at runtime or pass a specified number of bytes to
> user's browser. I provide a link to the user and when he clicks the link i
> want a file dialog to appear and the user can then give a file name to
> store those bytes as a file.
>
> The problem is i need to create links dynamically and supply the binary or
> image bytes as a file download to user. How can i do this?
>
> Can someone help me out here?
>
> Thanks in advance
> enzeez



 
Reply With Quote
 
 
 
 
enzeez
Guest
Posts: n/a
 
      04-03-2008
Augustin Prasanna wrote:
Augustin Prasanna wrote:
> I am sure your table will have a primary key and you will be using the
> primary key to fetch the content
>
> 1) Link to some page like download.aspx and pass the key value (e.g. <a
> href="download.aspx?fileid=1234">download</a>)
> 2) In download.aspx codebehind, write code to retrieve the content for this
> Id
> 3) Write the resultset to using Response.binarywrite
>
> below is a asp code snippet which almost does the same.
>
> response.clear
> response.contentType = "application/octet-stream"
> response.addheader "content-disposition", "attachment; filename=" & FileName
> set stream = server.CreateObject("ADODB.Stream")
> stream.type = adTypeBinary
> stream.open
> stream.LoadFromFile Server.MapPath("/files") & FileName
> while not stream.EOS
> response.BinaryWrite Stream.Read(1024 * 64)
> wend
> stream.Close
> Set stream = Nothing
> response.Flush
> response.End
>
>
> Regards,
> Augustin Prasanna
>
> "enzeez" <(E-Mail Removed)> wrote in message
> news:u$(E-Mail Removed)...
>> Hello,
>>
>> I have a record stored in sqlserver database in binary form.
>> I want to display a link that will allow user to download this record as a
>> File.
>>
>> I want to create a file at runtime or pass a specified number of bytes to
>> user's browser. I provide a link to the user and when he clicks the link i
>> want a file dialog to appear and the user can then give a file name to
>> store those bytes as a file.
>>
>> The problem is i need to create links dynamically and supply the binary or
>> image bytes as a file download to user. How can i do this?
>>
>> Can someone help me out here?
>>
>> Thanks in advance
>> enzeez

>
>


> I am sure your table will have a primary key and you will be using the
> primary key to fetch the content
>
> 1) Link to some page like download.aspx and pass the key value (e.g. <a
> href="download.aspx?fileid=1234">download</a>)
> 2) In download.aspx codebehind, write code to retrieve the content for this
> Id
> 3) Write the resultset to using Response.binarywrite
>
> below is a asp code snippet which almost does the same.
>
> response.clear
> response.contentType = "application/octet-stream"
> response.addheader "content-disposition", "attachment; filename=" & FileName
> set stream = server.CreateObject("ADODB.Stream")
> stream.type = adTypeBinary
> stream.open
> stream.LoadFromFile Server.MapPath("/files") & FileName
> while not stream.EOS
> response.BinaryWrite Stream.Read(1024 * 64)
> wend
> stream.Close
> Set stream = Nothing
> response.Flush
> response.End
>
>
> Regards,
> Augustin Prasanna
>
> "enzeez" <(E-Mail Removed)> wrote in message
> news:u$(E-Mail Removed)...
>> Hello,
>>
>> I have a record stored in sqlserver database in binary form.
>> I want to display a link that will allow user to download this record as a
>> File.
>>
>> I want to create a file at runtime or pass a specified number of bytes to
>> user's browser. I provide a link to the user and when he clicks the link i
>> want a file dialog to appear and the user can then give a file name to
>> store those bytes as a file.
>>
>> The problem is i need to create links dynamically and supply the binary or
>> image bytes as a file download to user. How can i do this?
>>
>> Can someone help me out here?
>>
>> Thanks in advance
>> enzeez

>
>

Thank you.
This solves my problem
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments