EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Problems with "read" callback

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#32062
Posted: 02/03/2015 05:50:25
by Vincent MARTINON (Basic support level)
Joined: 02/03/2015
Posts: 2

Hello,

I'm trying the CBFS product (evaluation key for now) in order to build a "box like" integration in windows explorer for a product we commercialize in our company.

For now, we don't want to handle a local storage and manage synchronisation.
We only want to be able to browser in windows explorer, as a disk, our remote data.
I access to this data through REST services available on our product.

For now, my first tests were great !
The only problems I have are to read file content.

2 problems :

- I implemented the CbFsReadFile method to call my remote file download; so I read in remote stream to return progressively bytes read. It's working well, event on big files but not with some applications.
To explain, if I open a big text file, it's fine; but if I open a ZIP file (even very small), it's working with 7Zip but not with windows standard ZIP application. I have same problem with Ms Word documents for example.
I have the message my file is not valid.
Do you know what could be the reason ?
Is my method correct ?

- When I open a folder, I'm called on CbFsEnumerateDirectory callback and I answer with my subfiles but for each of my file, I'm called on read method. With big files and remote access some of my folders are very slow to open because of that.
Can I disable this "read" call ? Can I test the context to not return the file content in this case ?

My read code if it can help :
Code
public void Read(byte[] ReadBuf, long Position, int BytesToRead, ref int BytesRead)
{
   try
   {
      if (binaryReader == null)
      {
         // First call : we call remote service and get stream
         WebResponse webResponse = FlowUtils.getFileContent(mpc.Token, mpc.Url, file.Uri);
         Stream currentStream = webResponse.GetResponseStream();
         binaryReader = new BinaryReader(currentStream);
      }
      
      byte[] tmpReadBuf = binaryReader.ReadBytes(BytesToRead);
      Array.Copy(tmpReadBuf, ReadBuf, tmpReadBuf.Length);
      BytesRead = tmpReadBuf.Length;
   }
   catch (Exception e)
   {
      System.Diagnostics.Debug.WriteLine(e);
   }
}


Thank you for your help,

Vincent.
#32066
Posted: 02/03/2015 06:38:38
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

Quote
Vincent MARTINON wrote:
To explain, if I open a big text file, it's fine; but if I open a ZIP file (even very small), it's working with 7Zip but not with windows standard ZIP application. I have same problem with Ms Word documents for example. I have the message my file is not valid. Do you know what could be the reason ? Is my method correct ?


Your implementation for reading callback handler is not correct. Eg. reading can start from any position, not from the beginning of the file. You don't take Position parameter into account.

Quote
Vincent MARTINON wrote:
- When I open a folder, I'm called on CbFsEnumerateDirectory callback and I answer with my subfiles but for each of my file, I'm called on read method. With big files and remote access some of my folders are very slow to open because of that. Can I disable this "read" call ? Can I test the context to not return the file content in this case ?


This question is asked all the time here and we have an article in the FAQ about it.


Sincerely yours
Eugene Mayevski
#32067
Posted: 02/03/2015 06:44:42
by Vincent MARTINON (Basic support level)
Joined: 02/03/2015
Posts: 2

Thank you for your 2 answers.
I'll fix my code with your advices.

Vincent.

Reply

Statistics

Topic viewed 1681 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!