Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading News attachment from file in database D2L Valence API
    text
    copied!<p>I'm having some issue with <strong>uploading file attachments for News</strong> in Valence API. I'm using PHP and when I try to make a post request, the action never gets completed. I'm running it on command line so I have to kill the process to terminate the program.</p> <p>My file data and details(Name, Type and Size) are stored in the database and I'm using just <strong>one call to post everything</strong> i.e. the News in JSON Format and the file attachments. I'm using the following format for the post message (As mentioned in the API docs):</p> <p>Content-Type: multipart/mixed; boundary=e9e1c17c958e2a89a192bf5d3f7d1ffd Content-Length: 46538</p> <p>--e9e1c17c958e2a89a192bf5d3f7d1ffd Content-Type: application/json</p> <p>{"Title":"Some News","Body":{"Text":"This &lt;/span>is a very &lt;/span>colorful title&lt;/span>","Html":"This &lt;/span>is a very &lt;/span>colorful title&lt;/span>"},"StartDate":"2013-11-06T05:00:00.000Z","EndDate":"2013-11-30T05:00:00.000Z","IsGlobal":false,"IsPublished":true,"ShowOnlyInCourseOfferings":false}</p> <p>--e9e1c17c958e2a89a192bf5d3f7d1ffd Content-Disposition: form-data; name="FC.png"; filename="FC.png"</p> <p>Content-Type: image/png</p> <p>{} --e9e1c17c958e2a89a192bf5d3f7d1ffd--</p> <p>I <strong>can't see the file content</strong> due to encoding I guess. I'm calculating the content-length in this message as: <strong>string length of the JSON data + filesize in bytes</strong>.</p> <p>My very speicific question is that can one post files from the database directly or it's recommended to write the file to the disk first then try posting. I would also appreciate if someone can point me to an example online where there's a pre-existing sample code using PHP for this.</p> <p>One more thing. If I do not include the file-size in bytes for the content-length, then it works fine except for the file attachment. It is 29 bytes in size and when I click on it, it opens with corrupt data error.</p> <p>Any kind of help will be appreciated. Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload