GenApi FileControl upload and download

(On standby: I’m investigating bugs in my code…)
I’m tasked with storing an arbitrary file on board a camera.

Using Sapera CamExpert, I’ve found that I can upload and download a file in the Miscellaneous in the User defined image ‘slot’.

Checking from within GeniCam Browser, I can then see that the userDefinedSavedImage has changed size, but I can’t work out how to use the UI from there to check or change its contents.

But the reason I’m fighting with both of these is because the following code is doing nothing (not throwing or complaining, but the downloaded file is empty):

GenApi.NMUploadFile(nodes.Handle, "userDefinedSavedImage ", "TestFileIn.json");
GenApi.NMDownloadFile(nodes.Handle, "userDefinedSavedImage ", "TestFileOut.json");

The only things I can think of is that the enum string is wrong, or that I shouldn’t be passing nodes.Handle for GenApi.NODEMAP.

Any pointers?

Hi @Ben,

from the description I guess that you are using a Genie Nano camera, because that camera offers this functionality.
I checked the behaviour using a Genie Nano in CVB 14.00.006 (behaviour should be the same in the newest version). I actually do not see the case that the downloaded file is empty. Since I was using C# the syntax is a bit different, but the C# wrapper should use the same function as you did in the background.

files of the type *.bmp, *.xml or *.json can be uploaded and downloaded without any issue.

      NodeMap deviceNodeMap = firstDevice.NodeMaps[NodeMapNames.Device];      
      deviceNodeMap.UploadFile("i.json", "userDefinedSavedImage");
      Console.WriteLine("File Uploaded");
      deviceNodeMap.DownloadFile("i_down.json", "userDefinedSavedImage");
      Console.WriteLine("File Downloaded");

The difference I noticed from you code snipped is that

"userDefinedSavedImage " 

should not be used with a space at the end. Using this term I get an exception in C#. So I am a bit wondering why you do not receive an exception.

Which CVB version are you using?
Could you insert your *.json file here for download?

2 Likes

@Simon, thanks for taking the time to answer.

I don’t know why, but when searching for upload I came across the old version first, and didn’t notice/find the .NET version. And when I tried it just now (before seeing your answer), I stupidly just removed the handle parameter, and didn’t notice the other two were inverted!

So now it works, thank you so much.

2 Likes