-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Part 3 - applying file URL or path improvement #17149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1aef040
3d6ce07
54a0c8d
49b328f
d174051
9e11477
8a57ff3
9bf8aad
c104045
5624c24
fe3bb7e
fed67fa
b560b05
04ae59a
69bbb92
094bf97
0107ed6
8aa2266
ed11f6e
1afc1fa
c0438fb
055a2e4
b6a68ad
9158a07
c34250f
e89430f
d8e872a
30630a8
bd3923b
4448b2a
9d2183e
b7b190b
9053265
371c5d4
486ec3f
0033db0
729cc67
f398a11
b85f1c4
ed11cce
d4150b2
e5adcbc
91bf402
747949b
8636bd2
43a3eed
a781302
6944ee2
f03921e
78c7203
14881d4
68b0157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,13 +1,12 @@ | ||||||
import meistertask from "../../meistertask.app.mjs"; | ||||||
import FormData from "form-data"; | ||||||
import fs from "fs"; | ||||||
import { ConfigurationError } from "@pipedream/platform"; | ||||||
import { getFileStreamAndMetadata } from "@pipedream/platform"; | ||||||
|
||||||
export default { | ||||||
key: "meistertask-create-attachment", | ||||||
name: "Create Attachment", | ||||||
description: "Create a new attachment. [See the docs](https://developers.meistertask.com/reference/post-attachment)", | ||||||
version: "0.0.1", | ||||||
version: "0.1.0", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we were changing to major version
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only if a prop name is changed or props are added/removed, as that requires user action after updating. If the props are kept the same, users can update and their input will remain functional (if the prop takes a path to /tmp and/or a URL) |
||||||
type: "action", | ||||||
props: { | ||||||
meistertask, | ||||||
|
@@ -40,8 +39,8 @@ export default { | |||||
}, | ||||||
filepath: { | ||||||
type: "string", | ||||||
label: "File Path", | ||||||
description: "Path of the file in /tmp folder to add as an attachment. To upload a file to /tmp folder, please follow the [doc here](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", | ||||||
label: "File Path or URL", | ||||||
description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)", | ||||||
}, | ||||||
name: { | ||||||
type: "string", | ||||||
|
@@ -50,14 +49,6 @@ export default { | |||||
optional: true, | ||||||
}, | ||||||
}, | ||||||
methods: { | ||||||
checkTmp(filename) { | ||||||
if (filename.indexOf("/tmp") === -1) { | ||||||
return `/tmp/${filename}`; | ||||||
} | ||||||
return filename; | ||||||
}, | ||||||
}, | ||||||
async run({ $ }) { | ||||||
const { | ||||||
taskId, | ||||||
|
@@ -66,16 +57,14 @@ export default { | |||||
} = this; | ||||||
|
||||||
const data = new FormData(); | ||||||
const path = this.checkTmp(filepath); | ||||||
|
||||||
if (!fs.existsSync(path)) { | ||||||
throw new ConfigurationError("File does not exist"); | ||||||
} | ||||||
|
||||||
const file = fs.createReadStream(path); | ||||||
const stats = fs.statSync(path); | ||||||
data.append("local", file, { | ||||||
knownLength: stats.size, | ||||||
const { | ||||||
stream, metadata, | ||||||
} = await getFileStreamAndMetadata(filepath); | ||||||
data.append("local", stream, { | ||||||
contentType: metadata.contentType, | ||||||
knownLength: metadata.size, | ||||||
filename: metadata.name, | ||||||
}); | ||||||
if (name) { | ||||||
data.append("name", name); | ||||||
|
@@ -85,6 +74,7 @@ export default { | |||||
}; | ||||||
|
||||||
const response = await this.meistertask.createAttachment({ | ||||||
$, | ||||||
taskId, | ||||||
data, | ||||||
headers, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ export default { | |
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you omit this kind of changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always hide whitespace changes when reviewing the PR, this was likely done by ESLint when merging with master and think it's easier to merge it since it will keep happening to any future branches until it's merged