-
Re: How to upload aa image from a Custom View Tile?
Robert Hanson Oct 18, 2016 5:44 AM (in response to Robert Hanson)Ryan Rutan Rashed Talukder is it possible to get an official response to whether or not this is possible?
Thanks.
-
Re: How to upload aa image from a Custom View Tile?
Rashed Talukder Oct 18, 2016 8:00 AM (in response to Robert Hanson)Hi Robert,
I'd recommend using Core to make REST API requests instead of using the JS API's for consistency. Here's an example:
osapi.jive.core.get({
v : "v3",
href : /v3/contents/82821,
})
.execute(function(response) {
console.log(response);
}
This was recommended to me by our professional services team and how I have been making any REST API request.
-
Re: How to upload aa image from a Custom View Tile?
Robert Hanson Oct 18, 2016 11:46 AM (in response to Rashed Talukder)Rashed Talukder, according to those docs it can't be used to post binary data. Are you saying that page is inaccurate?
From: Making REST API calls directly from a Jive app or tile
Known limitations:
- This feature does not work for binary payloads.
I experiment using that to post binary data and let you know how it goes.
-
Re: How to upload aa image from a Custom View Tile?
Robert Hanson Oct 19, 2016 8:42 AM (in response to Rashed Talukder)The following code returned a HTTP 415 (unsupported media type) for me.
var theFile = document.getElementsByTagName('input')[0].files[0];
console.log(theFile);
var formData = new FormData();
formData.append("file", theFile);
osapi.jive.core.post({
v: "v3",
href: "/images",
body: formData
})
.execute(function(response) {
console.log(JSON.stringify(response));
});
The file data is present, and this is what the console.log at line #2 returns.
- File {name: "Screen Shot 2016-10-18 at 4.33.14 PM.png", lastModified: 1476822807000, lastModifiedDate: Tue Oct 18 2016 16:33:27 GMT-0400 (EDT), webkitRelativePath: "", size: 4899…}
- lastModified:1476822807000
- lastModifiedDate:Tue Oct 18 2016 16:33:27 GMT-0400 (EDT)
- name:"Screen Shot 2016-10-18 at 4.33.14 PM.png"
- size:4899
- type:"image/png"
- webkitRelativePath:""
- __proto__:File
The use of the FormData object is because that endpoint requires a multipart/form-data request. However it doesn't look like Jive's API supports this.
This is what is actually sent to Jive:
- [{"method":"jive.core.post","id":"jive.core.post","params":{"v":"v3","href":"/images","body":{},"userId":"@viewer","groupId":"@self"}}]
From what I see it looks like Jive only allows a JSON body, which I don't think will work for a REST endpoint that only accepts mutipart/form-data.
Can you confirm my findings? Or if I am doing it wrong can you provide an example?
If what I am seeing is correct, I think we are back to the original question.
Thanks.
-
Re: How to upload a image from a Custom View Tile?
john.boloian@nuance.com Mar 21, 2017 1:31 PM (in response to Robert Hanson)Hi Robert Hanson - Were you ever able to figure this out, I'm trying to do something similar (upload a file as an attachment to a document) and running into the same issues.
Cheers,
-
Re: How to upload a image from a Custom View Tile?
Robert Hanson Mar 21, 2017 2:05 PM (in response to john.boloian@nuance.com)1 person found this helpfulHi John Boloian. It doesn't appear that it's possible with the current JS API, but there are ways to do it.
In our case we are opting (probably) to develop a middleware service, so when you upload the file via the tile it will be posted to the middleware instead of Jive. From there the middleware can post the file into Jive. It means that we will have to host a middleware app somewhere, but from the user's point of view it will all be seamless.
Alternatively I found this post, Performing a Secure Multi-Part POST from within a Jive App. I haven't tried this yet, but it could be a solution for this.
-
Re: How to upload a image from a Custom View Tile?
john.boloian@nuance.com Mar 22, 2017 8:09 AM (in response to Robert Hanson)Thanks Robert – I am looking into using this, would prefer this over middleware. I will comment about how this solution works out. Thanks!
-
Re: How to upload a image from a Custom View Tile?
john.boloian@nuance.com Mar 24, 2017 3:11 PM (in response to Robert Hanson)An update, I was able to do this using the help that Robert Hanson pointed to: Performing a Secure Multi-Part POST from within a Jive App. Thanks again for the help.
One thing I haven't been able to figure out is how to receive a response once the attachment(s) have been successfully uploaded to the content. I'm finding that if the user navigates from the page too soon, the attachment doesn't successfully get posted (I'm guessing since the request is still in a "pending" status.
-
Re: How to upload a image from a Custom View Tile?
michael_yegorov Apr 4, 2017 7:32 AM (in response to john.boloian@nuance.com)John Boloian, if you actually manage to upload file with this guide, maybe you can provide me with some details about how you did it, because I'm failing so far.
1) Were you doing it in app or in custom-view tile?
2) Is there a tile domain security turned on on your instance?
3) What you did with "setupToken" function? It's description is missing.
-
Re: How to upload a image from a Custom View Tile?
john.boloian@nuance.com Apr 4, 2017 8:08 AM (in response to michael_yegorov)1 person found this helpfulHi Michael Yegorov -
I was able to do it in a custom-view tile. We are on the cloud.
I took out the setupToken function line, and appended 2 hidden form inputs (j-form-token and jive.token.name) - You could also put these in the HTML of the form as well.
This is the updated code I used:
var submitForm = function(v3uri, callback){ var $postForm = $("#j-post-form"); $postForm.append('<input type="hidden" class="j-form-token">'); $postForm.append('<input type="hidden" name="jive.token.name">'); osapi.jive.core.container.requestXJToken( {}, function(newToken) { var tokenName = newToken['jive.token.name']; $postForm.find('.j-form-token') .attr('name', tokenName) .val(newToken[tokenName]); $postForm.find('input[name=\'jive.token.name\']').val(tokenName); var jiveURL = getJiveURL(); var actionURL = jiveURL + '/api/core/v3' + v3uri; $postForm .attr('action', actionURL) .attr('method', 'post') .attr('target', 'uploadFrame') .removeAttr('onsubmit'); // Set any other form post data you need to set before uploading postCallback = callback; $postForm.submit(); }); }
-
Re: How to upload a image from a Custom View Tile?
michael_yegorov Apr 4, 2017 8:32 AM (in response to john.boloian@nuance.com)Yep, I did the same. Not working.
Also:
1) Your request is to upload the image with '/images' endpoint, or you're uploading an attachment to the document?2) Do you actually upload the image, or it's something else, like providing a url for an image hosted elsewhere and expecting jive to download it to its internal storage?
-
Re: How to upload a image from a Custom View Tile?
satyam@spglobal.com Apr 13, 2018 6:25 AM (in response to michael_yegorov)Hi Ryan Rutan Jens Goldhammer,
Is there a way we can achieve an image upload now using the custom view tile.
Thanks,
Satyam.
-
Re: How to upload a image from a Custom View Tile?
satyam@spglobal.com May 22, 2019 7:14 AM (in response to satyam@spglobal.com)Hi Team Jens Goldhammer Gopi Gorantala
Has anything changed here. Is there a way to do this now?
Thanks,
Satyam.
-
-
-
-
-
-
-
- File {name: "Screen Shot 2016-10-18 at 4.33.14 PM.png", lastModified: 1476822807000, lastModifiedDate: Tue Oct 18 2016 16:33:27 GMT-0400 (EDT), webkitRelativePath: "", size: 4899…}
-
-