I am using the following code to hide the download url of files on my website. The code uses Response.Binary write to send file to the client.
Kindly indicate the maximum size of the file that can be downloaded using this method.
I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate what can be done to ensure that the above method remains valid for any file size download.
call Response.AddHea der("Content-Disposition","a ttachment; filename=""" & strFileSave & """")
Response.Conten tType = "bad/type"
Set Fsys = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set TS = Fsys.GetFile(st rFile).OpenAsTe xtStream(1, -1)
Do While Not (TS.AtEndOfStre am)
Response.Binary Write(TS.Read(1 ))
Loop 14 11911
"S N" wrote:
I am using the following code to hide the download url of files on my website. The code uses Response.Binary write to send file to the client.
Kindly indicate the maximum size of the file that can be downloaded using this method.
call Response.AddHea der("Content-Disposition","a ttachment; filename=""" & strFileSave & """")
Response.Conten tType = "bad/type"
Set Fsys = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set TS = Fsys.GetFile(st rFile).OpenAsTe xtStream(1, -1)
Do While Not (TS.AtEndOfStre am)
Response.Binary Write(TS.Read(1 ))
Loop
Ummm...that code isn't goint to work, anyway. See the method
OpenAsTEXTstrea m
???
You really can only use FileSystemObjec t reliably with text files; it wasn't
designed to work with binary files.
You need to use ADODB.Stream object, instead. http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
And then you could easily control the amount you write in each chunk by just
limiting the amount you Read each time.
Thanks for the advice. I was under the impression that ADODB can be used
only for databases. This is the first instance of using it on files.
Can you please provide a sample code to hide download url by using ADODB
stream, while there should be no limit on the size of files to be
downloaded.
..
"Old Pedant" <Ol*******@disc ussions.microso ft.comwrote in message
news:C3******** *************** ***********@mic rosoft.com...
"S N" wrote:
>I am using the following code to hide the download url of files on my website. The code uses Response.Binary write to send file to the client. Kindly indicate the maximum size of the file that can be downloaded using this method. call Response.AddHea der("Content-Disposition","a ttachment; filename=""" & strFileSave & """") Response.Conten tType = "bad/type" Set Fsys = Server.CreateOb ject("Scripting .FileSystemObje ct") Set TS = Fsys.GetFile(st rFile).OpenAsTe xtStream(1, -1) Do While Not (TS.AtEndOfStre am) Response.Binary Write(TS.Read(1 )) Loop
Ummm...that code isn't goint to work, anyway. See the method
OpenAsTEXTstrea m
???
You really can only use FileSystemObjec t reliably with text files; it
wasn't
designed to work with binary files.
You need to use ADODB.Stream object, instead. http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx
And then you could easily control the amount you write in each chunk by
just
limiting the amount you Read each time.
I would be grateful if you can give me vbscript code as well.
I would also like to clarify that the code for jscript forces save as
dialog. What if we want to hide the download url but dont want to force the
save as dialog, instead just want to see the pdf file within the browser
window itself.
Kindly advise on this.
Thanks in anticipation.
"Old Pedant" <Ol*******@disc ussions.microso ft.comwrote in message
news:03******** *************** ***********@mic rosoft.com...
>
"S N" wrote:
>Can you please provide a sample code to hide download url by using ADODB stream, while there should be no limit on the size of files to be downloaded.
Good old Atrax has a couple of demos.
Note that his code is written in JScript for ASP, but conversion to
VBScript
should be easy.
http://rtfm.atrax.co.uk/infinitemonk...es/asp/934.asp
and http://rtfm.atrax.co.uk/infinitemonk...es/asp/935.asp
If you need more help, ask.
"S N" <ua******@yahoo .comwrote in message
news:un******** ******@TK2MSFTN GP05.phx.gbl...
>I am using the following code to hide the download url of files on my website. The code uses Response.Binary write to send file to the >client. Kindly indicate the maximum size of the file that can be downloaded using this method. I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate what can be done to >ensure that the above method remains valid for any file size download.
call Response.AddHea der("Content-Disposition","a ttachment; filename=""" & strFileSave & """")
Response.Conten tType = "bad/type"
Set Fsys = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set TS = Fsys.GetFile(st rFile).OpenAsTe xtStream(1, -1)
Do While Not (TS.AtEndOfStre am)
Response.Binary Write(TS.Read(1 ))
Loop
Use this code:-
Sub SendFileToRespo nse(FilePath, FileName)
Const clChunkSize = 1048576 ' 1MB
Dim oStream, i
Response.Buffer = False
Response.Conten tType = "applicatio n/octet-stream"
Response.AddHea der "Content-Disposition", _
"attachment ; Filename=" & FileName
Set oStream = Server.CreateOb ject("ADODB.Str eam")
oStream.Type = 1 ' Binary
oStream.Open
oStream.LoadFro mFile FilePath
For i = 1 To oStream.Size \ clChunkSize
Response.Binary Write oStream.Read(cl ChunkSize)
Next
If (oStream.Size Mod clChunkSize) <0 Then
Response.Binary Write oStream.Read(oS tream.Size Mod clChunkSize)
End If
oStream.Close
End Sub
SendFileToRespo nse strFile, strFileSave
Note the Response.Buffer = false allows you to send a file of any size.
--
Anthony Jones - MVP ASP/ASP.NET
What if we want to use sendfiletorespo nse but dont want to force the save as
dialog, instead just want to see the pdf file within the browser window
itself.
is there any change required in the code to achieve this.
"Anthony Jones" <An***********@ yadayadayada.co mwrote in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
>
"S N" <ua******@yahoo .comwrote in message
news:un******** ******@TK2MSFTN GP05.phx.gbl...
>>I am using the following code to hide the download url of files on my website. The code uses Response.Binary write to send file to the >client. Kindly indicate the maximum size of the file that can be downloaded using this method. I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate what can be done to >ensure that the above method remains valid for any file size download.
call Response.AddHea der("Content-Disposition","a ttachment; filename=""" & strFileSave & """") Response.Conten tType = "bad/type" Set Fsys = Server.CreateOb ject("Scripting .FileSystemObje ct") Set TS = Fsys.GetFile(st rFile).OpenAsTe xtStream(1, -1) Do While Not (TS.AtEndOfStre am) Response.Binary Write(TS.Read(1 )) Loop
Use this code:-
Sub SendFileToRespo nse(FilePath, FileName)
Const clChunkSize = 1048576 ' 1MB
Dim oStream, i
Response.Buffer = False
Response.Conten tType = "applicatio n/octet-stream"
Response.AddHea der "Content-Disposition", _
"attachment ; Filename=" & FileName
Set oStream = Server.CreateOb ject("ADODB.Str eam")
oStream.Type = 1 ' Binary
oStream.Open
oStream.LoadFro mFile FilePath
For i = 1 To oStream.Size \ clChunkSize
Response.Binary Write oStream.Read(cl ChunkSize)
Next
If (oStream.Size Mod clChunkSize) <0 Then
Response.Binary Write oStream.Read(oS tream.Size Mod clChunkSize)
End If
oStream.Close
End Sub
SendFileToRespo nse strFile, strFileSave
Note the Response.Buffer = false allows you to send a file of any size.
--
Anthony Jones - MVP ASP/ASP.NET
"S N" <ua******@yahoo .comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
What if we want to use sendfiletorespo nse but dont want to force the save
as dialog, instead just want to see the pdf file within the browser window
itself.
is there any change required in the code to achieve this.
If you know its a pdf then change content-type to application/pdf and remove
the attachment; keyword from content-disposition.
--
Anthony Jones - MVP ASP/ASP.NET
Following error received:
Response object error 'ASP 0157 : 80004005'
Buffering On
/test/dl.asp, line 2
Buffering cannot be turned off once it is already turned on.
Please note that I am hosting the site on a public server so there is no way
to ask the web admin to configure the server specifically for me. In such a
situation is it possible to eliminate the error as indicated above. Further,
if I am not able to switch off the response.buffer , will there be any
limitation on the size of file that i can download using
response.binary write?
"Anthony Jones" <An***********@ yadayadayada.co mwrote in message
news:e9******** ******@TK2MSFTN GP02.phx.gbl...
"S N" <ua******@yahoo .comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>What if we want to use sendfiletorespo nse but dont want to force the save as dialog, instead just want to see the pdf file within the browser window itself. is there any change required in the code to achieve this.
If you know its a pdf then change content-type to application/pdf and
remove the attachment; keyword from content-disposition.
--
Anthony Jones - MVP ASP/ASP.NET
"S N" <ua******@yahoo .comwrote in message
news:u4******** ******@TK2MSFTN GP06.phx.gbl...
Following error received:
Response object error 'ASP 0157 : 80004005'
Buffering On
/test/dl.asp, line 2
Buffering cannot be turned off once it is already turned on.
You get this error if there is anything in your page or includes at the top
of the page which writes stuff to the response before your code has run.
Note any static content in the page will be sent.
Typical a page of this sort looks like:-
<!-- #include .... some common include -->
<%
' Code here that should note writing anything.
'My code I posted to you with your mods.
%>
Where the include is of a similar structure defininng constants and utility
functions.
>
Please note that I am hosting the site on a public server so there is no
way to ask the web admin to configure the server specifically for me.
Whilst an admin may have configured the buffer to be on (which is the
default) you can set it off as long as you do so before sending anything.
>In such a situation is it possible to eliminate the error as indicated above. Further, if I am not able to switch off the response.buffer , will there be any limitation on the size of file that i can download using response.binar ywrite?
Without turning it off there will be a limitation. The is a buffer size
limit that a public server administrator will almost certainly have
configured (the default on IIS6 is 4MB).
--
Anthony Jones - MVP ASP/ASP.NET This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Milan |
last post by:
Hi!
I am loading XML file this way:
oDom = Server.CreateObject("Microsoft.XMLDOM")
oDom.async = False
If oDom.Load(Server.MapPath("lang/EN.xml")) Then
GetXMLDocument = oDom.documentElement
Else
|
by: steve |
last post by:
I am setting up a huge database in mysql, and I get the above error in
Linux. I believe it is related to the size of one of my tables, which
is 4,294,966,772 bytes in size. Can someone help. How can I break
that barrier.
A google search did not turn up anything useful.
--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
|
by: Peter Ballard |
last post by:
Hi all,
I've got a C program which outputs all its data using a statement of
the form:
putchar(ch, outfile);
This has worked fine for years until it had to output more than 2GB of
data today, and I got a "file size limit exceeded" error.
|
by: Ben |
last post by:
I use the following method to export data to an excel
file. Is there a size limit? It seems that the size is
big (about 2, 3 MB), it hangs when attempt to open the
file.
Response.Clear() ;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader ("Content-
Disposition", "attachment;filename=list.doc") ;
Response.Write ("<TABLE border=1 cellPadding=1
|
by: Amod |
last post by:
Hi,
I m copying data from a video stream on the hard disk using a C++
programme in win32 API. my current file system is FAT32 .. the file
size limit of FAT32 is 4GB. I want to automatically split the file if
the file size is greater than 4GB and create a new file with the
incoming data. How can I perform the above task . Please guide me.
Regards,
Amod
| |
by: Amod |
last post by:
Hi,
I m copying data from a video stream on the hard disk using a C++
programme in win32 API. my current file system is FAT32 .. the file
size limit of FAT32 is 4GB. I want to automatically split the file if
the file size is greater than 4GB and create a new file with the
incoming data. How can I perform the above task . Please guide me.
Regards,
Amod
|
by: eastcoastguyz |
last post by:
I wrote a simple program to continue to create a very large file (on
purpose), and even though there is plenty of disk space on that device
the program aborted with the error message "File Size Limit Exceeded".
The file size was 2147483647. I checked ulimit -a and its set to
unlimited.
Is this a compiler issue? I would like to see a C code example of how
to increase the limit or make it unlimited (if that is a wise thing to
do).
|
by: MichiMichi |
last post by:
I am trying to secure filedownload via streaming to protect files on
the server. This works very well but when I open the file in a notepad
editor it shows always HTML code at the end of the file.
Since the code runs in a aspx file, the added HTML Code always
streamed at the end.
What do I have to do so the files are stored without the HTML tags on
the client machine?
|
by: S N |
last post by:
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client.
Kindly indicate the maximum size of the file that can be downloaded using this method.
I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate what can be done to ensure that the above method remains valid for any file size download.
call...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |