-
Re: Binary Data Storage - Seeking working example
Robert Hanson Aug 9, 2017 8:59 AM (in response to Robert Hanson)1 person found this helpfulSolved.
The important bit is that when you upload the content to Jive that the content type isn't mixed/multipart (aka form data), it is just the binary content. That means you only send the Blob object and not a FormData object, and you set the content type to application/octet-stream.
// get a temp BDS token to POST the attachment osapi.jive.binary.token({duration : 10, name : 'readme.txt', verb : 'POST' }).execute(function(response) { // temp URL to POST the attachment var postUrl = response.url; // create a Blob (file-api) with the file content var blob = new Blob(["Hello World"], {type : 'text/plain'}); // fd.append('file', blob, "readme.txt"); // use the temp token to post the content with jQuery. // important: this is different from a upload, the content type isn't a mixed/multipart. $.ajax({ url: postUrl, data: blob, processData: false, contentType: 'application/octet-stream', type: 'POST', success: function(data){ // fetch a new BDS token to GET the attachment osapi.jive.binary.token({name: 'readme.txt', verb: 'GET'}) .execute(function(response) { // temp URL to GET the attachment var getUrl = response.url; // create a new Discussion object and add the attachment URL var attachment = {doUpload: true, "url": getUrl}; var discussion = { content: {type: 'text/html', text: 'A Document'}, subject: 'Some Discussion', attachments: [attachment]}; // use the JS API to create the Discussion and attachment osapi.jive.corev3.discussions.create(discussion) .execute(function (response) { console.log(response); }); }); } }); });
-
Re: Binary Data Storage - Seeking working example
iainbrown Dec 2, 2014 5:07 AM (in response to Robert Hanson)Robert Hanson have you been able to upload binary direct to a file? i.e using the ref: parameter in the binary token request. I've got a working example that creates files in the apps binary storage, but I'm trying to now add a file in a group, but I'm getting errors.
As per Binary Data Storage Usage I am adding the ref parameter: /attachment for the indirect method and it appears to be giving me a URL ok, but if I switch to /group as in section 4 of the instructions I get errors like: "Reference parameter does not refer to a valid parent object".
Would be interested to know if you were creating Jive files at any point successfully?
-
Re: Binary Data Storage - Seeking working example
iainbrown Dec 2, 2014 5:12 AM (in response to iainbrown)Of course, now I got to the point of asking the question, I figured it out after significant trial and error.
/groups/<numerical groupid> is the required reference, not the self.ref as stated in the docs. I'll comment over there.
-
-
Re: Binary Data Storage - Seeking working example
cgarnitz Aug 9, 2017 7:25 AM (in response to Robert Hanson)1 person found this helpfulHello Robert Hanson,
thanks for the nice code example but i want to mention for anybody who tries this that there is a bug in line 10. It can be deleted because its not needed and it works without this line.
-
Re: Binary Data Storage - Seeking working example
Robert Hanson Aug 9, 2017 9:00 AM (in response to cgarnitz)I updated the code and commented out the line. I didn't delete it because I didn't want to confuse anyone reading through this thread and saw a mention of deleting line 10.
-
Re: Binary Data Storage - Seeking working example
cgarnitz Aug 10, 2017 1:55 AM (in response to Robert Hanson)Hi Robert Hanson,
thank you! I have one question regarding this method, did you use it for images as attachments?
Because i noticed a weird bug with PNGs and some JPGs. When uploading them to the binary storage it works nicely but when creating the discussion or document i get weird errors or the file gets corrupted.Did you notice that too?
-
Re: Binary Data Storage - Seeking working example
Robert Hanson Aug 10, 2017 5:56 AM (in response to cgarnitz)I have one question regarding this method, did you use it for images as attachments?
Because i noticed a weird bug with PNGs and some JPGs. When uploading them to the binary storage it works nicely but when creating the discussion or document i get weird errors or the file gets corrupted.
Did you notice that too?
No images, I was using it to create and attach text files.
If you need to upload images from an App (not sure about tiles), you might want to check out Performing a Secure Multi-Part POST from within a Jive App. I haven't tried this myself, but I believe that someone reported getting it to work.
-
Re: Binary Data Storage - Seeking working example
Nils DrewsOct 16, 2017 11:12 AM (in response to cgarnitz)
Just to close the loop: This is a weird bug in Jive which is fixed on cloud. Somehow streams getting mangeled in between.
-
-
-
-