Skip to content

Commit

Permalink
Merge pull request #2796 from Vitalini/main
Browse files Browse the repository at this point in the history
feat(google-drive): added file content type to upload file action
  • Loading branch information
abuaboud committed Sep 25, 2023
2 parents 85264ef + ac6283b commit b4dd02a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/google-drive/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-google-drive",
"version": "0.5.2"
"version": "0.5.3"
}
2 changes: 1 addition & 1 deletion packages/pieces/google-drive/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const googleDrive = createPiece({
logoUrl: 'https://cdn.activepieces.com/pieces/google-drive.png',
actions: [googleDriveCreateNewFolder, googleDriveCreateNewTextFile, googleDriveUploadFile, readFile],
displayName: "Google Drive",
authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau'],
authors: ['kanarelo', 'BastienMe', 'MoShizzle', 'Armangiau', 'vitalini'],
triggers: [newFile, newFolder],
auth: googleDriveAuth,
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,31 @@ export const googleDriveCreateNewTextFile = createAction({
description: 'The text content to add to file',
required: true,
}),
fileType: Property.StaticDropdown({
displayName: 'Content type',
description: 'Select file type',
required: true,
defaultValue: 'plain/text',
options: {
options: [
{
label: 'Text', value: 'plain/text',
},
{
label: 'CSV', value: 'text/csv',
},
{
label: 'XML', value: 'text/xml',
},
],
},
}),
parentFolder: common.properties.parentFolder,
include_team_drives: common.properties.include_team_drives
},
async run(context) {
const meta = {
'mimeType': "plain/text",
'mimeType': context.propsValue.fileType,
'name': context.propsValue.fileName,
...(context.propsValue.parentFolder ? { 'parents': [context.propsValue.parentFolder] } : {})
}
Expand All @@ -35,7 +54,7 @@ export const googleDriveCreateNewTextFile = createAction({

const form = new FormData()
form.append("Metadata", metaBuffer, { contentType: 'application/json' });
form.append("Media", textBuffer, { contentType: 'plain/text' });
form.append("Media", textBuffer, { contentType: context.propsValue.fileType });

const result = await httpClient.sendRequest({
method: HttpMethod.POST,
Expand Down

0 comments on commit b4dd02a

Please sign in to comment.