PHP Classes

box.com File Upload Example

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  box.com File Upload Example  >  (Un) Subscribe thread alerts  
Subject:box.com File Upload Example
Summary:box.com File Upload Example
Messages:4
Author:George Lerma
Date:2014-08-15 15:30:38
 

  1. box.com File Upload Example   Reply   Report abuse  
Picture of George Lerma George Lerma - 2014-08-15 15:30:38
I was wondering if you might be able to help once more, this time for a file upload operation.

The required elements are:
filename The name of the file to be uploaded
Type: string

parent_id The ID of folder where this file should be uploaded
Type: string

MEthod:
POST https://upload.box.com/api/2.0/files/content

Curl Example:
curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer ACCESS_TOKEN" \
-F filename=@FILE_NAME \
-F parent_id=PARENT_FOLDER_ID

  2. Re: box.com File Upload Example   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-08-15 21:52:33 - In reply to message 1 from George Lerma
Try this:

$success = $client->CallAPI(
"https://upload.box.com/api/2.0/files/content",
'POST', array(
'parent_id'=>'PARENT_FOLDER_ID',
'filename'=>'FILE_NAME'
),array(
'FailOnAccessError'=>true,
'Files'=>array(
'filename'=>array(
)
)
), $results);

  3. Re: box.com File Upload Example   Reply   Report abuse  
Picture of George Lerma George Lerma - 2014-08-22 20:22:12 - In reply to message 2 from Manuel Lemos
Hmm... I'm getting : "Error: it was not possible to access the API call: it was returned an unexpected response status 400 Response: {"type":"error","status":400,"code":"invalid_request_parameters","help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Invalid input parameters in request","request_id":"98364666653f7a5dd15425"}"



Here is my call:

Here is what I have.
$file_name='testfile.txt';
$parent_id=2325536685;
$parameters = array('filename'=>$file_name, 'parent_id'=>$parent_id);
$success = $client->CallAPI(
"https://upload.box.com/api/2.0/files/content",
'POST', $parameters
,array(
'FailOnAccessError'=>true,
'Files'=>array('filename'=>array())
), $results);

Is there a way to debug the actual request being sent?

Thanks again for your help.
George

  4. Re: box.com File Upload Example   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-08-22 21:13:10 - In reply to message 3 from George Lerma
The request seems correct. The error message seems to say that request_id parameter seems incorrect but I do not see it in the code you mention.

Anyway, you can see the debug output in the PHP error log by setting the debug and debug_http variables to true.