multi-file update
This commit is contained in:
@@ -34,6 +34,30 @@ export async function uploadToDrive(accessToken: string, fileName: string, conte
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateDriveFile(accessToken: string, fileId: string, content: string) {
|
||||
const auth = new google.auth.OAuth2();
|
||||
auth.setCredentials({ access_token: accessToken });
|
||||
|
||||
const drive = google.drive({ version: 'v3', auth });
|
||||
|
||||
const media = {
|
||||
mimeType: 'text/markdown',
|
||||
body: Readable.from([content]),
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await drive.files.update({
|
||||
fileId,
|
||||
media,
|
||||
fields: 'id, webViewLink',
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error updating Google Drive file:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function generateReportMarkdown(report: any) {
|
||||
let md = `# WFH Daily Report - ${new Date(report.date).toLocaleDateString()}\n`;
|
||||
md += `**Employee:** ${report.user.name}\n`;
|
||||
|
||||
Reference in New Issue
Block a user