내가 잘못했을 때를 맞히겠습니다.하지만 제가 수행 한 FAQ에 따라 javacript 클라이언트 라이브러리 https://developers.google.com/api-client-library/javascript/reference/referencedocs은 웹 응용 프로그램에만 사용됩니다. 나는 사용자가 google 드라이브에 그림을 업로드 할 수 있어야하는 phonegap를 사용하여 모바일 앱을 만들고 있습니다. 나는이 연결을 통해 갈 것이다 : https://developers.google.com/drive/v2/reference/files/insertphonegap과 함께 API를 사용하여 google 드라이브에 파일 업로드
당신이 볼 수 있던대로, 나는 파일을 업로드하기 위하여 javascript 클라이언트 도서관을 이용한다. 해당 라이브러리를 사용하지 않고도 할 수있는 방법이 있습니까? 그렇다면 순수 js 또는 jquery를 사용하여 어떻게 할 수 있습니까?
감사
감사 JunYoung ... 난 당신이 로그인 권한을 부여에서 부분을 마무리 할 수 있었다. 이제 내가하려는 것은 내 드라이브에 파일을 업로드하는 것입니다. 모든 예제는 JS 클라이언트 라이브러리를 사용합니다. https://developers.google.com/drive/quickstart-js gapi.client.request를 사용하지 않고 동일하게 실행하려고합니다. 간단한 POST를 사용하고 싶습니다. 여기에 당신은 내가 간단한 아약스 호출로 gapi.client.request 일부를 교체 한 볼 수 있듯이 내 코드
const boundary = '-------314159265358979323846';
const delimiter = "\r\n--" + boundary + "\r\n";
const close_delim = "\r\n--" + boundary + "--";
var reader = new FileReader();
var fileContent = this.$.fileInput.getFiles()[0];
reader.readAsBinaryString(fileContent);
reader.onload = function(e) {
var contentType = fileContent.type || 'application/octet-stream';
var metadata = {
'title': fileContent.name,
'mimeType': contentType
};
var base64Data = btoa(reader.result);
var multipartRequestBody =
delimiter +
'Content-Type: application/json\r\n\r\n' + JSON.stringify(metadata) + delimiter + 'Content-Type: ' + contentType + '\r\n' + 'Content-Transfer-Encoding: base64\r\n' + '\r\n' + base64Data + close_delim;
var driveAjax = new enyo.Ajax({
url: 'https://www.googleapis.com/upload/drive/v2/files',
method: 'POST',
contentType: 'multipart/mixed; boundary="' + boundary + '"',
postBody: multipartRequestBody
});
driveAjax.response(this, "uploadSuccess");
driveAjax.error(this, "processError");
driveAjax.go({
uploadType:'multipart'
});
입니다. 그러나 이것은 효과가없는 것 같습니다. BTW 나는 enyo js 프레임 워크를 사용하고 있습니다. 이 문제를 발견 할 수 있습니까?
내 대답을 확인할 수 있습니다. [질문] (http://stackoverflow.com/questions/35746756/how-implement-google-drive-in-ionic-app/42412306) 코드가있는 앱에 Google 드라이브를 통합 할 때의 문제 – JcDenton86