ofFile to ofBuffer and vice versa to send via ofxPocoNetwork

I am trying to send some ofFiles via udp using ofxPocoNetwork

before sending anything I am trying to simply convert an ofFile to an ofBuffer and then back to ofFile again.

shouldn’t this be working?

ofFile in;"",false).getPath());

in.copyTo(ofSystemSaveDialog("","").getPath(),false);//THIS WORKS
ofBuffer buf(in);

//client.sendMessage(buf);//later on

ofFile out(buf);
out.copyTo(ofSystemSaveDialog("","").getPath(),false);//THIS DOESN'T (copyTo(): source file does not exist)

I haven’t tested latest branch yet…

I’m not sure about out.copyTo()…Looking at the docs for the constructor, it looks like you can pass in a filename as a string, or an existing ofFile object, but not a buffer. Since the ofFile out object doesn’t point to a filename, it makes sense (to me at least) that you can’t copy it somewhere.

Instead, since you’ve already got the contents in an ofBuffer you could use ofBufferToFile()!show_ofBufferToFile

yes I see,
this works great: (tested it on osx)

ofBuffer fileAsBuffer = ofBufferFromFile(ofSystemLoadDialog("",false).getPath(), true);



anybody knows
what is the maximum size limit this addon can handle for sending a buffer without corrupting it?

also how can I send an information string with the message?


so that I know what extension is the file I am sending?

something like the address() in the osc addon

hm… same code doesn’t work under Windows

Not sure if it is a bug in our implementation of OPENFILENAMEW and lpstrFilter in ofSystemSaveDialog
or a bug in ofBuffer in the ofBufferToFile functions