【问题标题】:Dynamically Add Content in Google Drive Document File在 Google Drive 文档文件中动态添加内容
【发布时间】:2018-10-10 00:15:51
【问题描述】:

我已经创建了动态文件,在我必须从 fckeditor 添加一些动态内容之后,在保存按钮上的该文件上添加内容或文本。在 PHP 中使用 google drive API 的 java 脚本代码添加 google 文档文件。

【问题讨论】:

    标签: javascript jquery google-drive-api google-drive-realtime-api


    【解决方案1】:

    function gd_updateFile()
                    {
                        var my_text = "your content";
    
                        var folderId  =  "fileid";
                        var fileId = "your folder id ";
    
    
                        const boundary = '-------314159265358979323846';
                        const delimiter = "\r\n--" + boundary + "\r\n";
                        const close_delim = "\r\n--" + boundary + "--";
    
                        var contentType = "text/html";
                        var metadata = {'mimeType': contentType,};
    
                        var multipartRequestBody =
                            delimiter +  'Content-Type: application/json\r\n\r\n' +
                            JSON.stringify(metadata) +
                            delimiter + 'Content-Type: ' + contentType + '\r\n' + '\r\n' +
                            my_text +
                            close_delim;
    
    
                        var request  = gapi.client.request({
                            'path': '/upload/drive/v2/files/'+folderId+"?fileId="+fileId+"&uploadType=multipart",
                            'method': 'PUT',
                            'params': {'fileId': fileId, 'uploadType': 'multipart'},
                            'headers': {'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'},
                            'body': multipartRequestBody,
                            callback:callback,
                    	});
    
    
    
                        $(".update_file_out_put").html(callback);
    
                    	if (!callback) 
                        	{ 
                        		callback = function(file) 
                        		{ 
                                	//console.log(file);
                        		}; 
                        	}
                    }

    【讨论】:

      猜你喜欢
      • 2013-01-14
      • 2021-08-18
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-10
      相关资源
      最近更新 更多