J
Joseph Geretz
Up to this point, our application has been using Windows File Sharing to
transfer files to and from our application document repository. This
approach does not lend itself toward a secure environment and so we are in
the process of imposing a WebService gateway between our application client
and the repository.
(As a starting point, the WebService won't be a richly featured application
server; business rules are still implemented in the client. But this will
ensure that all access to the document repository is made via our software.
Although the WebMethod below accepts only a single parameter, I'll shortly
be adding authentication parameters to this method to ensure that accesses
to this WebMethod actually originate from our client application.)
Here is the method which I've defined (below). I have two questions, one
which relates to functionality, and the other which relates to performance.
1. I can't get this to work! When I test this I get the following error
message:
Could not open C:\Winzip.log --> Access to the path
"C:\Winzip.log" is denied.
Here's the line of code on which the exception occurs:
FileStream FS = new FileStream(FileSpec, FileMode.Open);
I can't imagine that this is a Windows security problem. I have anonymous
access disabled, integrated Windows authentication enabled, so the request
must be running using my credentials and I'm able to open this file via the
Windows shell. I imagine that perhaps I need to tweak a setting somewhere,
but I'm not sure where.
2. Is this the quickest way to stream a file back to a remote client? Speedy
delivery of the document to the client is critical and so anything that I
can do to improve performance is important to me. Maybe conversion to
Base64String is not as efficient? If I can use a more efficient format I
will. Just bear in mind that I need to stream binary files (e.g. JPG) as
well as textual, so I need a format which will preserve every bit as it
travels via HTTP.
Thanks very much for your advice!
- Joe Geretz -
[WebMethod]
public string GetFileStream(string FileSpec)
{
try
{
FileStream FS = new FileStream(FileSpec, FileMode.Open);
byte[] FileBytes = new byte[FS.Length];
FS.Read(FileBytes, 0, (int)FS.Length);
FS.Close();
return System.Convert.ToBase64String(FileBytes, 0, FileBytes.Length);
}
catch (Exception e)
{
throw new Exception("Could not open " + FileSpec, e);
}
}
transfer files to and from our application document repository. This
approach does not lend itself toward a secure environment and so we are in
the process of imposing a WebService gateway between our application client
and the repository.
(As a starting point, the WebService won't be a richly featured application
server; business rules are still implemented in the client. But this will
ensure that all access to the document repository is made via our software.
Although the WebMethod below accepts only a single parameter, I'll shortly
be adding authentication parameters to this method to ensure that accesses
to this WebMethod actually originate from our client application.)
Here is the method which I've defined (below). I have two questions, one
which relates to functionality, and the other which relates to performance.
1. I can't get this to work! When I test this I get the following error
message:
Could not open C:\Winzip.log --> Access to the path
"C:\Winzip.log" is denied.
Here's the line of code on which the exception occurs:
FileStream FS = new FileStream(FileSpec, FileMode.Open);
I can't imagine that this is a Windows security problem. I have anonymous
access disabled, integrated Windows authentication enabled, so the request
must be running using my credentials and I'm able to open this file via the
Windows shell. I imagine that perhaps I need to tweak a setting somewhere,
but I'm not sure where.
2. Is this the quickest way to stream a file back to a remote client? Speedy
delivery of the document to the client is critical and so anything that I
can do to improve performance is important to me. Maybe conversion to
Base64String is not as efficient? If I can use a more efficient format I
will. Just bear in mind that I need to stream binary files (e.g. JPG) as
well as textual, so I need a format which will preserve every bit as it
travels via HTTP.
Thanks very much for your advice!
- Joe Geretz -
[WebMethod]
public string GetFileStream(string FileSpec)
{
try
{
FileStream FS = new FileStream(FileSpec, FileMode.Open);
byte[] FileBytes = new byte[FS.Length];
FS.Read(FileBytes, 0, (int)FS.Length);
FS.Close();
return System.Convert.ToBase64String(FileBytes, 0, FileBytes.Length);
}
catch (Exception e)
{
throw new Exception("Could not open " + FileSpec, e);
}
}