Hello,
I'm currently working on the integration of BaseX in part of our .Net based software. One part of the functionality will be to store and retrieve binary files. I haven't been able to retrieve the raw files from the server yet using C#. I based my solution on the example of the C# client in the source code repository of BaseX. With my current solution I receive only the first few (3 to 7) bytes of the file (at least I think they are...).
The code I have at the moment is:
/// <summary> /// Retrieves a RAW document from the database. The database must be opened before executing this command. /// </summary> /// <param name="path">The path to the binary data to be retrieved</param> /// <returns>A byte array with the binary data</returns> public byte[] Retrieve(string path) { //stream.WriteByte((byte)BaseXCommand.QUERY); Send("RETRIEVE " + path); //Send(path);
using (MemoryStream ms = new MemoryStream()) { Receive(ms); info = Receive(); if (!Ok()) { throw new IOException(info); } return ms.ToArray(); } }
Can anybody please tell me what the problem with this solution can be or give me a hint for a correct way to retrieve the raw bytes? I know I can use the files on disk directly, but would rather not go that way.
Thanks in advance for your reaction!
Kind regards,
Björn Boxstart
Hi Björn,
sorry for letting you wait. I have just updated the C# code [1] (see [2] for more details). Could you give it another try?
Thanks, Christian
PS: We are looking for users who help us to update the client bindings to the new 8.0 authentication. It should be fairly easy to realize; if you may be interested, please tell me!
[1] https://github.com/BaseXdb/basex/commit/d49901c022117d5ae9a014f67a1e214fa82a... [2] http://docs.basex.org/wiki/Server_Protocol#Transfer_Protocol
On Tue, Dec 30, 2014 at 3:40 PM, Boxstart, Bjorn Bjorn_Boxstart@reyrey.com wrote:
Hello,
I’m currently working on the integration of BaseX in part of our .Net based software. One part of the functionality will be to store and retrieve binary files. I haven’t been able to retrieve the raw files from the server yet using C#. I based my solution on the example of the C# client in the source code repository of BaseX. With my current solution I receive only the first few (3 to 7) bytes of the file (at least I think they are…).
The code I have at the moment is:
/// <summary>
/// Retrieves a RAW document from the database. The database must be
opened before executing this command.
/// </summary> /// <param name="path">The path to the binary data to be
retrieved</param>
/// <returns>A byte array with the binary data</returns> public byte[] Retrieve(string path) { //stream.WriteByte((byte)BaseXCommand.QUERY); Send("RETRIEVE " + path); //Send(path); using (MemoryStream ms = new MemoryStream()) { Receive(ms); info = Receive(); if (!Ok()) { throw new IOException(info); } return ms.ToArray(); } }
Can anybody please tell me what the problem with this solution can be or give me a hint for a correct way to retrieve the raw bytes? I know I can use the files on disk directly, but would rather not go that way.
Thanks in advance for your reaction!
Kind regards,
Björn Boxstart
Hello Christian,
Thanks a lot for the modification. This works like a charm! I will take a look at the 8.0 authentication and give you a reply when I would like to start working on this.
Kind regards, Björn Boxstart
-----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: dinsdag 6 januari 2015 11:43 Aan: Boxstart, Bjorn CC: basex-talk@mailman.uni-konstanz.de Onderwerp: Re: [basex-talk] Fetching a binary document from BaseX with C# using the server API
Hi Björn,
sorry for letting you wait. I have just updated the C# code [1] (see [2] for more details). Could you give it another try?
Thanks, Christian
PS: We are looking for users who help us to update the client bindings to the new 8.0 authentication. It should be fairly easy to realize; if you may be interested, please tell me!
[1] https://github.com/BaseXdb/basex/commit/d49901c022117d5ae9a014f67a1e214fa82a... [2] http://docs.basex.org/wiki/Server_Protocol#Transfer_Protocol
On Tue, Dec 30, 2014 at 3:40 PM, Boxstart, Bjorn Bjorn_Boxstart@reyrey.com wrote:
Hello,
I’m currently working on the integration of BaseX in part of our .Net based software. One part of the functionality will be to store and retrieve binary files. I haven’t been able to retrieve the raw files from the server yet using C#. I based my solution on the example of the C# client in the source code repository of BaseX. With my current solution I receive only the first few (3 to 7) bytes of the file (at least I think they are…).
The code I have at the moment is:
/// <summary>
/// Retrieves a RAW document from the database. The database
must be opened before executing this command.
/// </summary> /// <param name="path">The path to the binary data to be
retrieved</param>
/// <returns>A byte array with the binary data</returns> public byte[] Retrieve(string path) { //stream.WriteByte((byte)BaseXCommand.QUERY); Send("RETRIEVE " + path); //Send(path); using (MemoryStream ms = new MemoryStream()) { Receive(ms); info = Receive(); if (!Ok()) { throw new IOException(info); } return ms.ToArray(); } }
Can anybody please tell me what the problem with this solution can be or give me a hint for a correct way to retrieve the raw bytes? I know I can use the files on disk directly, but would rather not go that way.
Thanks in advance for your reaction!
Kind regards,
Björn Boxstart
basex-talk@mailman.uni-konstanz.de