Skip to content

Commit

Permalink
file upload issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
udhayakumar-d committed Dec 20, 2018
1 parent 115fcbc commit 604175e
Showing 1 changed file with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions lib/ZohoCrmHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,19 @@ var ZOHO = (function() {
data['sdkVersion'] = '1';
return appSDK.getContext().Event.Trigger('CRM_EVENT', data, true);
}

// file upload issue fie
function createNewFileObj(file)
{
var oldfile = file;
var newfile = new File([oldfile], oldfile.name, { type: oldfile.type });
return newfile;
}
function createRecord(Entity, APIdata, RecordID, RelatedEntity) {

if(APIdata.FileData)
{
var newfileObj = createNewFileObj(APIdata.FileData);
APIdata.FileData = newfileObj;
}
var data = {
category: "CREATE", //no i18n
Entity: Entity,
Expand Down Expand Up @@ -69,6 +79,11 @@ var ZOHO = (function() {
};
function uploadFile(APIData)
{
if(APIData.FILE)
{
var newfileobj = createNewFileObj(APIData.FILE.file);
APIData.FILE.file = newfileobj;
}
var data = {
FileData : APIData,
category : "FILES", //no i18n
Expand Down Expand Up @@ -211,6 +226,11 @@ var ZOHO = (function() {
};

function remoteCall(method, requestData, type) {
if(requestData.FILE)
{
var newfileobj = createNewFileObj(requestData.FILE.file);
requestData.FILE.file = newfileobj;
}
var reqData = undefined;
if (!type) {
var url = requestData.url;
Expand Down Expand Up @@ -5406,6 +5426,46 @@ var ZOHO = (function() {
*/
patch: function(data) {
return remoteCall(HTTPRequest.PATCH, data);
},
/**
* @function delete
* @description Invoke HTTP delete
* @returns {Promise} resolved with response of the initiated request
* @memberof ZOHO.CRM.HTTP
* @param {Object} request - Request Object
* @param {Object} request.params - Request Params
* @param {Object} request.headers - Request Headers
* @param {Object} request.body - Request Body
* @example
* var request ={
* url : "https://crm.zoho.com/crm/v2/Leads/111158000000045188",
* headers:{
* Authorization:"******************************",
* }
* }
* ZOHO.CRM.HTTP.delete(request)
* .then(function(data){
* console.log(data)
* })
*
* //Prints
*
*{
* "data": [
* {
* "code": "SUCCESS",
* "details": {
* "id": "111158000000045188"
* },
* "message": "record deleted",
* "status": "success"
* }
* ]
*}
*
*/
delete: function(data) {
return remoteCall(HTTPRequest.DELETE, data);
}
},
/**
Expand Down

0 comments on commit 604175e

Please sign in to comment.