function output = uploadToGoogle(dropboxAccessToken,varargin)
...
dataFile = varargin{1};
...
try
fid = fopen(dataFile, 'r');
data = char(fread(fid)');
fclose(fid);
catch someException
throw(addCause(MException('uploadToGoogle:unableToReadFile','Unable to read input file.'),someException));
end
[~,remoteFName, remoteExt] = fileparts(dataFile);
headerFields = {'Authorization', ['Bearer ', dropboxAccessToken]};
headerFields{2,1} = 'Content-Type';
headerFields{2,2} = 'application/octet-stream';
headerFields = string(headerFields);
opt = weboptions;
opt.MediaType = 'application/octet-stream';
opt.CharacterEncoding = 'ISO-8859-1';
opt.RequestMethod = 'post';
opt.HeaderFields = headerFields;
try
tempOutput = webwrite('https://www.googleapis.com/upload/drive/v3/files?uploadType=media', data, opt);
catch someException
throw(addCause(MException('uploadToGoogle:unableToUploadFile','Unable to upload file.'),someException));
end
...