Using SetToFile for upload

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Using SetToFile for upload

Postby litereddonut » Mon Sep 15, 2014 3:19 pm

I'm using SetToFile to upload some files, but keep running into a problem where the chromium log message says "[0915/131408:FATAL:resource_dispatcher_host_impl.cc(212)] Check failed: false. Denied unauthorized upload of <FILEPATH>"

I'm digging through the call stack and the problem is in "ShouldServiceRequest" in chromium, "policy->CanReadFile(child_id, iter->path())" is returning false. I've examined the permissions on the file and it seems like reading should be allowed. Here is the source code when I call SetToFile.

Code: Select all
CefRefPtr<CefPostDataElement> postDataElement(CefPostDataElement::Create());
   
postDataElement->SetToFile(mUploadFilePath);
CefRefPtr<CefPostData> postData(CefPostData::Create());
bool b = postData->AddElement(postDataElement);

mRequest->SetPostData (postData);

mUrlRequest = CefURLRequest::Create(mRequest, this)


I am using CEF-1650. Any help would be appreciated.
litereddonut
Techie
 
Posts: 19
Joined: Mon Jun 03, 2013 3:06 pm

Re: Using SetToFile for upload

Postby magreenblatt » Mon Sep 15, 2014 3:24 pm

What CEF version and OS? Where are you executing this code from?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Using SetToFile for upload

Postby litereddonut » Mon Sep 15, 2014 3:52 pm

This is windows and CEF 1650 with chromium 31. I am extending the CefURLRequestClient class and trying to starting an upload.
litereddonut
Techie
 
Posts: 19
Joined: Mon Jun 03, 2013 3:06 pm

Re: Using SetToFile for upload

Postby magreenblatt » Mon Sep 15, 2014 4:01 pm

litereddonut wrote:This is windows and CEF 1650 with chromium 31. I am extending the CefURLRequestClient class and trying to starting an upload.

In what process are you executing the CefURLRequest?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Using SetToFile for upload

Postby litereddonut » Mon Sep 15, 2014 4:27 pm

The render process. I can successfully upload files if I do
Code: Select all
postDataElement3->SetToBytes(data.length(), data.c_str());
litereddonut
Techie
 
Posts: 19
Joined: Mon Jun 03, 2013 3:06 pm

Re: Using SetToFile for upload

Postby magreenblatt » Mon Sep 15, 2014 4:42 pm

Ok, your problem is that the render process cannot access arbitrary files due to security restrictions (further reinforced by the sandbox in newer CEF versions). You should initiate the CefURLRequest from the browser process instead.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Using SetToFile for upload

Postby litereddonut » Mon Sep 15, 2014 5:34 pm

Thanks, I will move it to the browser process.
litereddonut
Techie
 
Posts: 19
Joined: Mon Jun 03, 2013 3:06 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 47 guests