473,236 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

binary stream saving at server instead of client

Good Afternoon.

the code below is properly retreiving binary data from a database and saving
it. but instead of saving at client machine is saving at the server machine.
what is wrong with my code ??

thank you

Pedro Leite From Portugal
------------------------------------
<%
Function ReadBinaryData (FileName)

' Connection String
Dim connStr
connStr = "Provider=MSDASQL.1;Extended
Properties=Driver={Firebird/Interbase(r)
driver};Dbname=xxxxxxxxxxxxxxg21:/data/xxxxxxxxxxxxxxxxxxx.gdb;CHARSET=ISO8859_1;PWD=xxxx xxxxxxxxxxxx;UID=xxxxxxxxxxxxxxxxxxxx"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "SELECT NOME_LOGICO, FICHEIRO,MIME_TYPE FROM TCS_XIBFS Where
NOME_LOGICO = '" & FileName & "'", connStr, 2, 4

'Response.Clear()
'Response.ContentType = rs("MIME_TYPE")
'Response.BinaryWrite rs("FICHEIRO")
'Response.end

ReadBinaryData = rs("FICHEIRO")
rs.Close
Set rs = Nothing
End Function

Function WriteBinaryFile (BinaryData,FileName)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write BinaryData
response.write("<br>")
response.write(FileName)
response.write("<br>")
response.Write(BinaryData)
'Save binary data To disk
BinaryStream.SaveToFile "C:\f\" & FileName, adSaveCreateOverWrite
End Function

%>

</head>

<body>
<%
Dim Result

Response.write ReadBinaryData (Request.QueryString("doc"))

Result=WriteBinaryFile (ReadBinaryData
(Request.QueryString("doc")),"x.xls")
%>
Jun 16 '06 #1
4 6682
Nothing. Keep in mind that this code is executed server side, so c: is the
server side disk.

Try :
http://support.microsoft.com/kb/276488/en-US (using oledbstream to stream a
file to the browser)
http://support.microsoft.com/kb/260519/en-us (to force the save as dialog)

Note that the save as dialog can't be bypassed (else security would be
seriously compromised !) unless you have control on the client side config
(intranet) or users have allowed this explicitely (giving this right to
activex control, or java applets).

--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
Oh**************@TK2MSFTNGP04.phx.gbl...
Good Afternoon.

the code below is properly retreiving binary data from a database and
saving it. but instead of saving at client machine is saving at the server
machine.
what is wrong with my code ??

thank you

Pedro Leite From Portugal
------------------------------------
<%
Function ReadBinaryData (FileName)

' Connection String
Dim connStr
connStr = "Provider=MSDASQL.1;Extended
Properties=Driver={Firebird/Interbase(r)
driver};Dbname=xxxxxxxxxxxxxxg21:/data/xxxxxxxxxxxxxxxxxxx.gdb;CHARSET=ISO8859_1;PWD=xxxx xxxxxxxxxxxx;UID=xxxxxxxxxxxxxxxxxxxx"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "SELECT NOME_LOGICO, FICHEIRO,MIME_TYPE FROM TCS_XIBFS Where
NOME_LOGICO = '" & FileName & "'", connStr, 2, 4

'Response.Clear()
'Response.ContentType = rs("MIME_TYPE")
'Response.BinaryWrite rs("FICHEIRO")
'Response.end

ReadBinaryData = rs("FICHEIRO")
rs.Close
Set rs = Nothing
End Function

Function WriteBinaryFile (BinaryData,FileName)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write BinaryData
response.write("<br>")
response.write(FileName)
response.write("<br>")
response.Write(BinaryData)
'Save binary data To disk
BinaryStream.SaveToFile "C:\f\" & FileName, adSaveCreateOverWrite
End Function

%>

</head>

<body>
<%
Dim Result

Response.write ReadBinaryData (Request.QueryString("doc"))

Result=WriteBinaryFile (ReadBinaryData
(Request.QueryString("doc")),"x.xls")
%>

Jun 16 '06 #2
Thank you fo ryour help and clarification on this matter.

taking this a bit further, let's assume :

i run the code, saving at the server a given set of files, then using the
filesystemobject i can read the folder and create links like : blahblah
download.asp?file=whatever. this blank page would actualy read the file
according to http://support.microsoft.com/kb/276488/en-US, ie, adodb stream
from file, and then, prompt the user to save it wherever he wants to, and
thus, the file store would be protected from http download because is not
published.

my question is, and i think i know the answer ( no ). on page load, create a
folder named after the sessionID. do whatever i want and when work.commit,
clean the folder and remove it, this way, multi user concurrent access is
possible.

how can this be done in classic asp ?

Thank You

Pedro Leite
------------------------------------------------------------------------------------------------

"Patrice" <sc****@chez.com> escreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
Nothing. Keep in mind that this code is executed server side, so c: is the
server side disk.

Try :
http://support.microsoft.com/kb/276488/en-US (using oledbstream to stream
a file to the browser)
http://support.microsoft.com/kb/260519/en-us (to force the save as dialog)

Note that the save as dialog can't be bypassed (else security would be
seriously compromised !) unless you have control on the client side config
(intranet) or users have allowed this explicitely (giving this right to
activex control, or java applets).

--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
Oh**************@TK2MSFTNGP04.phx.gbl...
Good Afternoon.

the code below is properly retreiving binary data from a database and
saving it. but instead of saving at client machine is saving at the
server machine.
what is wrong with my code ??

thank you

Pedro Leite From Portugal
------------------------------------
<%
Function ReadBinaryData (FileName)

' Connection String
Dim connStr
connStr = "Provider=MSDASQL.1;Extended
Properties=Driver={Firebird/Interbase(r)
driver};Dbname=xxxxxxxxxxxxxxg21:/data/xxxxxxxxxxxxxxxxxxx.gdb;CHARSET=ISO8859_1;PWD=xxxx xxxxxxxxxxxx;UID=xxxxxxxxxxxxxxxxxxxx"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "SELECT NOME_LOGICO, FICHEIRO,MIME_TYPE FROM TCS_XIBFS Where
NOME_LOGICO = '" & FileName & "'", connStr, 2, 4

'Response.Clear()
'Response.ContentType = rs("MIME_TYPE")
'Response.BinaryWrite rs("FICHEIRO")
'Response.end

ReadBinaryData = rs("FICHEIRO")
rs.Close
Set rs = Nothing
End Function

Function WriteBinaryFile (BinaryData,FileName)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write BinaryData
response.write("<br>")
response.write(FileName)
response.write("<br>")
response.Write(BinaryData)
'Save binary data To disk
BinaryStream.SaveToFile "C:\f\" & FileName, adSaveCreateOverWrite
End Function

%>

</head>

<body>
<%
Dim Result

Response.write ReadBinaryData (Request.QueryString("doc"))

Result=WriteBinaryFile (ReadBinaryData
(Request.QueryString("doc")),"x.xls")
%>


Jun 16 '06 #3
IMO you could do that but I'm not sure what you are trying to do (not sure
which multi user concurrent access you are talking about).

If you mean that you would like to avoid retrieving the file several times
from the DB you could create a cache like system. For example something like
:
- if the file is found in the cache (a location outisde of the web site so
that direct download is not possible) get it from this location else get it
first from the db and save it as well to the cache
- you could purge older files (for example based on the access date so that
frequently).
- make sure the cache doesn't old and older version than the one currently
in the db

Another option would be to just store the files outside of the db (and keep
only their location in the db)
--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
uo**************@TK2MSFTNGP02.phx.gbl...
Thank you fo ryour help and clarification on this matter.

taking this a bit further, let's assume :

i run the code, saving at the server a given set of files, then using the
filesystemobject i can read the folder and create links like : blahblah
download.asp?file=whatever. this blank page would actualy read the file
according to http://support.microsoft.com/kb/276488/en-US, ie, adodb
stream from file, and then, prompt the user to save it wherever he wants
to, and thus, the file store would be protected from http download because
is not published.

my question is, and i think i know the answer ( no ). on page load, create
a folder named after the sessionID. do whatever i want and when
work.commit, clean the folder and remove it, this way, multi user
concurrent access is possible.

how can this be done in classic asp ?

Thank You

Pedro Leite
------------------------------------------------------------------------------------------------

"Patrice" <sc****@chez.com> escreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
Nothing. Keep in mind that this code is executed server side, so c: is
the server side disk.

Try :
http://support.microsoft.com/kb/276488/en-US (using oledbstream to stream
a file to the browser)
http://support.microsoft.com/kb/260519/en-us (to force the save as
dialog)

Note that the save as dialog can't be bypassed (else security would be
seriously compromised !) unless you have control on the client side
config (intranet) or users have allowed this explicitely (giving this
right to activex control, or java applets).

--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
Oh**************@TK2MSFTNGP04.phx.gbl...
Good Afternoon.

the code below is properly retreiving binary data from a database and
saving it. but instead of saving at client machine is saving at the
server machine.
what is wrong with my code ??

thank you

Pedro Leite From Portugal
------------------------------------
<%
Function ReadBinaryData (FileName)

' Connection String
Dim connStr
connStr = "Provider=MSDASQL.1;Extended
Properties=Driver={Firebird/Interbase(r)
driver};Dbname=xxxxxxxxxxxxxxg21:/data/xxxxxxxxxxxxxxxxxxx.gdb;CHARSET=ISO8859_1;PWD=xxxx xxxxxxxxxxxx;UID=xxxxxxxxxxxxxxxxxxxx"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "SELECT NOME_LOGICO, FICHEIRO,MIME_TYPE FROM TCS_XIBFS Where
NOME_LOGICO = '" & FileName & "'", connStr, 2, 4

'Response.Clear()
'Response.ContentType = rs("MIME_TYPE")
'Response.BinaryWrite rs("FICHEIRO")
'Response.end

ReadBinaryData = rs("FICHEIRO")
rs.Close
Set rs = Nothing
End Function

Function WriteBinaryFile (BinaryData,FileName)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write BinaryData
response.write("<br>")
response.write(FileName)
response.write("<br>")
response.Write(BinaryData)
'Save binary data To disk
BinaryStream.SaveToFile "C:\f\" & FileName, adSaveCreateOverWrite
End Function

%>

</head>

<body>
<%
Dim Result

Response.write ReadBinaryData (Request.QueryString("doc"))

Result=WriteBinaryFile (ReadBinaryData
(Request.QueryString("doc")),"x.xls")
%>



Jun 16 '06 #4
Hi.

Good Point.

I'll brief you on the purpose of the database and the document saving thing.

the database supports our ERP. one of the options is to include on the
database, any document pertainig to any given article, meaning that i can
upload tech data, production manager can upload size charts, design staff
can upload sketches, prints or colour samples and so on.
this way, for article A, there can be an x number of related documents,
uploaded from different sources and from workstations that can be locked
under the domain credentials or even powered off. Uploading to the database
is mandatory under these circumstances. well, the files could be uploaded to
the database server, but then, it could have some security impacts, as now,
only the data base port, the management port and ssh ports are open. sending
the files would probably require netbios to be open or at the least,
listening. and we are talking about a linux server to make things a bit
harder.

anyway, when i talk about multi user, on the context of an intranet/internet
portal, this is pretty much about it.

I am at the knitting mill and need to check the fabric specs. bring up the
browser, fetch the file and while i am at it, you are in the house, checking
the designs, one by one, for the same article. i print/save the file, end my
session, and the files you were also browsing are deleted on the process.
not very neat and professional.

my idea was to write the files in volume:/MySessionID/files and also on
volume:/YorSessionID/files so that we both can access and on the end, wrap
it up and not interferring with other users.

Thats pretty much the purpose of this module.

The cahe idea may work but there would be the problem of updated versions of
the documents. that would have to be controlled or to make it simple, do not
use a cache. i also had the idea of appending the username to the file, like
: "userDesign1.jpg" but the issue is the same. on leaving, how can i delete
files for user. of course, i could do it on the start of the page : delete
files for user, generate files for user. on next access, delete the same
files and re-generate.

could be, but i would like to delete on end of session.

Hope I made my purpose clear and that you can help me.

Thank you for your kind attention.

Pedro Leite
------------------------------------------------------------------------
"Patrice" <sc****@chez.com> escreveu na mensagem
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMO you could do that but I'm not sure what you are trying to do (not sure
which multi user concurrent access you are talking about).

If you mean that you would like to avoid retrieving the file several times
from the DB you could create a cache like system. For example something
like :
- if the file is found in the cache (a location outisde of the web site so
that direct download is not possible) get it from this location else get
it first from the db and save it as well to the cache
- you could purge older files (for example based on the access date so
that frequently).
- make sure the cache doesn't old and older version than the one currently
in the db

Another option would be to just store the files outside of the db (and
keep only their location in the db)
--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
uo**************@TK2MSFTNGP02.phx.gbl...
Thank you fo ryour help and clarification on this matter.

taking this a bit further, let's assume :

i run the code, saving at the server a given set of files, then using the
filesystemobject i can read the folder and create links like : blahblah
download.asp?file=whatever. this blank page would actualy read the file
according to http://support.microsoft.com/kb/276488/en-US, ie, adodb
stream from file, and then, prompt the user to save it wherever he wants
to, and thus, the file store would be protected from http download
because is not published.

my question is, and i think i know the answer ( no ). on page load,
create a folder named after the sessionID. do whatever i want and when
work.commit, clean the folder and remove it, this way, multi user
concurrent access is possible.

how can this be done in classic asp ?

Thank You

Pedro Leite
------------------------------------------------------------------------------------------------

"Patrice" <sc****@chez.com> escreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
Nothing. Keep in mind that this code is executed server side, so c: is
the server side disk.

Try :
http://support.microsoft.com/kb/276488/en-US (using oledbstream to
stream a file to the browser)
http://support.microsoft.com/kb/260519/en-us (to force the save as
dialog)

Note that the save as dialog can't be bypassed (else security would be
seriously compromised !) unless you have control on the client side
config (intranet) or users have allowed this explicitely (giving this
right to activex control, or java applets).

--
Patrice

"Pedro Leite" <naoehpreciso> a écrit dans le message de news:
Oh**************@TK2MSFTNGP04.phx.gbl...
Good Afternoon.

the code below is properly retreiving binary data from a database and
saving it. but instead of saving at client machine is saving at the
server machine.
what is wrong with my code ??

thank you

Pedro Leite From Portugal
------------------------------------
<%
Function ReadBinaryData (FileName)

' Connection String
Dim connStr
connStr = "Provider=MSDASQL.1;Extended
Properties=Driver={Firebird/Interbase(r)
driver};Dbname=xxxxxxxxxxxxxxg21:/data/xxxxxxxxxxxxxxxxxxx.gdb;CHARSET=ISO8859_1;PWD=xxxx xxxxxxxxxxxx;UID=xxxxxxxxxxxxxxxxxxxx"

' Recordset Object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
' opening connection
rs.Open "SELECT NOME_LOGICO, FICHEIRO,MIME_TYPE FROM TCS_XIBFS Where
NOME_LOGICO = '" & FileName & "'", connStr, 2, 4

'Response.Clear()
'Response.ContentType = rs("MIME_TYPE")
'Response.BinaryWrite rs("FICHEIRO")
'Response.end

ReadBinaryData = rs("FICHEIRO")
rs.Close
Set rs = Nothing
End Function

Function WriteBinaryFile (BinaryData,FileName)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary

'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write BinaryData
response.write("<br>")
response.write(FileName)
response.write("<br>")
response.Write(BinaryData)
'Save binary data To disk
BinaryStream.SaveToFile "C:\f\" & FileName, adSaveCreateOverWrite
End Function

%>

</head>

<body>
<%
Dim Result

Response.write ReadBinaryData (Request.QueryString("doc"))

Result=WriteBinaryFile (ReadBinaryData
(Request.QueryString("doc")),"x.xls")
%>



Jun 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Russ Reynolds | last post by:
Problem: I'm writing a client app. that needs to download an image file (non-text) from a remote location and save to the client machine. Here is what I have so far (pseudocode): import...
2
by: Lisa Pearlson | last post by:
Hi, My php application (on Apache/Linux) needs to do the following: The PHP script receives a request from a client (binary), asking for certain records of data. My PHP script loops through...
11
by: ajou_king | last post by:
I was running some tests on my Win32 1GHZ processor to see how long it would take to transmit objects numerous times via TCP/IP using C# ..NET Remoting vs the C++ trustworthy method of binary...
1
by: Gilad Kapelushnik | last post by:
Hello I need to send data (a whole class) from a Sever to a Client. I convert this class to a binary array using Binary Serialization: public byte ToBytes(){ try{ IFormatter formatter = new...
10
by: Niyazi | last post by:
Hi, I developed an application and I am using SQL Server 2000 developer edition. I create my database and I have also created tbl_USER table. I have an ID, RealName, UserName, and UserPassword...
2
by: gauravkhanna | last post by:
Hi All I need some help for the below problem: Scenario We need to send large binary files (audio file of about 10 MB or so) from the client machine (.Net Windows based application, located...
15
by: Jacques | last post by:
Hi I am an dotNet newby, so pardon my ignorance. I am looking for a method of saving/copying a managed class to a stream/file WITHOUT saving the object's state, eg. if I have a ref class with...
15
by: JoeC | last post by:
I am writing a program that I am trying to learn and save binary files. This is the page I found as a source: http://www.angelfire.com/country/aldev0/cpphowto/cpp_BinaryFileIO.html I have...
9
by: loudking | last post by:
Dear all, I am writing a client-server application and the client should upload a file to the server, then the server should display the content of the file in stdout. Because I have to deal...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.