OfxHttpUtils blocks files

Hi,

I’m trying to move a file just after uploading it.
But the file is blocked and I can not use it until the Thread where ofxHttpUtils was initiated is finished.

What is the best way to unlock file and use it right in even handler?

ofxHttpUtils upload_httpUtils;
ofxHttpForm form;


form.action = upload_action_url;
form.method = OFX_HTTP_POST;

form.addFormField("filename", fileName);
form.addFormField("type", type);
form.addFile("file", filePath);
form.addHeaderField("Authorization", "Bearer " + OAuthToken);

upload_httpUtils.submitForm(form);



void parseUploadResponse(ofxJSONElement responseMessage) {
	
	std::string mv_cmd = ("MOVE /Y " + filePath + " " + newPath);			
	system(mv_cmd.c_str());

}


The process cannot access the file because it is being used by another process.
    0 file(s) moved.

I would move the files into memory using ofBuffer to prevent simultaneous disk access.


This isn’t directly related, but …

ofxHTTP has examples of posting, including OAuth1+2, json, etc, files, etc.

https://github.com/bakercp/ofxHTTP/tree/develop/example_basic_client_post
https://github.com/bakercp/ofxHTTP/tree/develop/example_basic_client_post_json

e.g.

https://github.com/bakercp/ofxHTTP/blob/develop/libs/ofxHTTP/include/ofx/HTTP/OAuth10HTTPClient.h

Thanks Chris!

1 Like