I'm trying to upload a file with the Google Drive api, and I have the metadata correct, and I want to ensure that the actual file contents make it there. I have a simple page setup that looks like this:
<div id="upload"> <h6>File Upload Operations</h6> <input type="file" placeholder='file' name='fileToUpload'> <button id='uploadFile'>Upload File</button> </div> and I have a the javascript setup where the user is prompted to sign in first, and then they can upload a file. Here's the code: (currently only uploads the file metadata....)
let uploadButton = document.getElementById('uploadFile'); uploadButton.onclick = uploadFile; const uploadFile = () => { let ftu = document.getElementsByName('fileToUpload')[0].files[0]; console.dir(ftu); gapi.client.drive.files.create({ 'content-type': 'application/json;charset=utf-8', uploadType: 'multipart', name: ftu.name, mimeType: ftu.type, fields: 'id, name, kind' }).then(response => { console.dir(response); console.log(`File: ${ftu.name} with MimeType of: ${ftu.type}`); //Need code to upload the file contents...... }); }; First, I'm more familiar with the back end, so getting the file in bits from the <input type='file'> tag is a bit nebulous for me. On the bright side, the metadata is there. How can I get the file contents up to the api?