Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Create a Text File",
description: "Creates a brand new text file from plain text content you specify. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-create-a-text-file",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
2 changes: 1 addition & 1 deletion components/dropbox/actions/create-folder/create-folder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Create folder",
description: "Create a Folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
key: "dropbox-create-folder",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Create or Append to a Text File",
description: "Adds a new line to an existing text file, or creates a file if it doesn't exist. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-create-or-append-to-a-text-file",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import common from "./common.mjs";
import consts from "../../common/consts.mjs";
import common from "./common.mjs";

export default {
name: "Create/Update a Share Link",
description: "Creates or updates a public share link to the file or folder (It allows you to share the file or folder with anyone). [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
key: "dropbox-create-update-share-link",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
...common.props,
alert: {

Check warning on line 12 in components/dropbox/actions/create-update-share-link/create-update-share-link.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 12 in components/dropbox/actions/create-update-share-link/create-update-share-link.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "warning",
content: `Dropbox Free and Basic users are able to create a publicly-available share link which allows downloads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Delete a File/Folder",
description: "Permanently removes a file/folder from the server. [See documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
key: "dropbox-delete-file-folder",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import dropbox from "../../dropbox.app.mjs";
import fs from "fs";
import { file } from "tmp-promise";
import got from "got";
import stream from "stream";
import { promisify } from "util";
import { checkTmp } from "../../common/utils.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Download File to TMP",
description: "Download a specific file to the temporary directory. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor).",
key: "dropbox-download-file-to-tmp",
version: "0.0.6",
version: "0.0.7",
type: "action",
props: {
dropbox,
Expand All @@ -27,30 +30,40 @@ export default {
},
},
async run({ $ }) {
const { result } = await this.dropbox.downloadFile({
path: this.dropbox.getNormalizedPath(this.path, false),
});
try {
const linkResponse = await this.dropbox.filesGetTemporaryLink({
path: this.dropbox.getNormalizedPath(this.path, false),
});

console.log("linkResponse: ", linkResponse);

const {
path, cleanup,
} = await file();
if (!linkResponse || !linkResponse.result) {
throw new Error("Failed to get temporary download link from Dropbox");
}

const extension = result.name.split(".").pop();
const {
link, metadata,
} = linkResponse.result;

const tmpPath = this.name
? `/tmp/${this.name}`
: `${path}.${extension}`;
const fileName = this.name || metadata.name;
const cleanFileName = fileName.replace(/[?$#&{}[]<>\*!@:\+\\\/]/g, "");

await fs.promises.appendFile(tmpPath, Buffer.from(result.fileBinary));
await cleanup();
const tmpPath = checkTmp(cleanFileName);
const pipeline = promisify(stream.pipeline);

delete result.fileBinary;
await pipeline(
got.stream(link),
fs.createWriteStream(tmpPath),
);

$.export("$summary", `File successfully saved in "${tmpPath}"`);
$.export("$summary", `File successfully saved in "${tmpPath}"`);

return {
tmpPath,
...result,
};
return {
tmpPath,
...metadata,
};
} catch (error) {
throw new Error(`Failed to download file: ${error.message}`);
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "List All Files/Subfolders in a Folder",
description: "Retrieves a list of files or subfolders in a specified folder [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor)",
key: "dropbox-list-file-folders-in-a-folder",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "List File Revisions",
description: "Retrieves a list of file revisions needed to recover previous content. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListRevisions__anchor)",
key: "dropbox-list-file-revisions",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Move a File/Folder",
description: "Moves a file or folder to a different location in the user's Dropbox [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
key: "dropbox-move-file-folder",
version: "0.0.11",
version: "0.0.12",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Rename a File/Folder",
description: "Renames a file or folder in the user's Dropbox [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
key: "dropbox-rename-file-folder",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
name: "Restore a File",
description: "Restores a previous file version. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesRestore__anchor)",
key: "dropbox-restore-a-file",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import dropbox from "../../dropbox.app.mjs";
import isNil from "lodash/isNil.js";
import consts from "../../common/consts.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Search files and folders",
description: "Searches for files and folders by name. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)",
key: "dropbox-search-files-folders",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
dropbox,
Expand Down
8 changes: 4 additions & 4 deletions components/dropbox/actions/upload-file/upload-file.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import dropbox from "../../dropbox.app.mjs";
import consts from "../../common/consts.mjs";
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import got from "got";
import { ConfigurationError } from "@pipedream/platform";
import consts from "../../common/consts.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Upload a File",
description: "Uploads a file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-upload-file",
version: "0.0.13",
version: "0.0.14",
type: "action",
props: {
dropbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import dropbox from "../../dropbox.app.mjs";
import consts from "../../common/consts.mjs";
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import got from "got";
import { ConfigurationError } from "@pipedream/platform";
import consts from "../../common/consts.mjs";
import dropbox from "../../dropbox.app.mjs";

export default {
name: "Upload Multiple Files",
description: "Uploads multiple file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
key: "dropbox-upload-multiple-files",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
dropbox,
Expand Down
6 changes: 6 additions & 0 deletions components/dropbox/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const checkTmp = (filename) => {
if (!filename.startsWith("/tmp")) {
return `/tmp/${filename}`;
}
return filename;
};
16 changes: 11 additions & 5 deletions components/dropbox/dropbox.app.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import dropbox from "dropbox";
import { Dropbox } from "dropbox";
import fetch from "isomorphic-fetch";
import get from "lodash/get.js";
import config from "./common/config.mjs";
import isString from "lodash/isString.js";
import isEmpty from "lodash/isEmpty.js";
import isNil from "lodash/isNil.js";

const Dropbox = dropbox.Dropbox;
import isString from "lodash/isString.js";
import config from "./common/config.mjs";

export default {
type: "app",
Expand Down Expand Up @@ -400,6 +398,14 @@ export default {
this.normalizeError(err);
}
},
async filesGetTemporaryLink(args) {
try {
const dpx = await this.sdk();
return await dpx.filesGetTemporaryLink(args);
} catch (err) {
this.normalizeError(err);
}
},
async downloadFile(args) {
try {
const dpx = await this.sdk();
Expand Down
8 changes: 5 additions & 3 deletions components/dropbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/dropbox",
"version": "0.4.0",
"version": "0.4.1",
"description": "Pipedream Dropbox Components",
"main": "dropbox.app.mjs",
"keywords": [
Expand All @@ -12,10 +12,12 @@
"dependencies": {
"@types/node-fetch": "^2.5.7",
"dropbox": "^10.34.0",
"got": "^14.0.0",
"got": "^13.0.0",
"isomorphic-fetch": "^3.0.0",
"lodash": "^4.17.21",
"tmp-promise": "^3.0.3"
"stream": "^0.0.3",
"tmp-promise": "^3.0.3",
"util": "^0.12.5"
},
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion components/dropbox/sources/all-updates/all-updates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
type: "source",
key: "dropbox-all-updates",
name: "New or Modified File or Folder",
version: "0.0.17",
version: "0.0.18",
description: "Emit new event when a file or folder is added or modified. Make sure the number of files/folders in the watched folder does not exceed 4000.",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/dropbox/sources/new-file/new-file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
type: "source",
key: "dropbox-new-file",
name: "New File",
version: "0.0.18",
version: "0.0.19",
description: "Emit new event when a new file is added to your account or a specific folder. Make sure the number of files/folders in the watched folder does not exceed 4000.",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/dropbox/sources/new-folder/new-folder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
type: "source",
key: "dropbox-new-folder",
name: "New Folder",
version: "0.0.17",
version: "0.0.18",
description: "Emit new event when a new folder is created. Make sure the number of files/folders in the watched folder does not exceed 4000.",
hooks: {
async activate() {
Expand Down
36 changes: 8 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading