000000001 avatar

000000001

Deprecated
View all Actors
This Actor is deprecated

This Actor is unavailable because the developer has decided to deprecate it. Would you like to try a similar Actor instead?

See alternative Actors
000000001

000000001

wjp/000000001

.editorconfig

1root = true
2
3[*]
4indent_style = space
5indent_size = 4
6charset = utf-8
7trim_trailing_whitespace = true
8insert_final_newline = true
9end_of_line = lf

.eslintrc

1{
2    "extends": "@apify"
3}

.gitignore

1# This file tells Git which files shouldn't be added to source control
2
3.idea
4node_modules

Dockerfile

1# First, specify the base Docker image. You can read more about
2# the available images at https://sdk.apify.com/docs/guides/docker-images
3# You can also use any other image from Docker Hub.
4FROM apify/actor-node:16
5
6# Second, copy just package.json and package-lock.json since it should be
7# the only file that affects "npm install" in the next step, to speed up the build
8COPY package*.json ./
9
10# Install NPM packages, skip optional and development dependencies to
11# keep the image small. Avoid logging too much and print the dependency
12# tree for debugging
13RUN npm --quiet set progress=false \
14 && npm install --only=prod --no-optional \
15 && echo "Installed NPM packages:" \
16 && (npm list || true) \
17 && echo "Node.js version:" \
18 && node --version \
19 && echo "NPM version:" \
20 && npm --version
21
22# Next, copy the remaining files and directories with the source code.
23# Since we do this after NPM install, quick build will be really fast
24# for most source file changes.
25COPY . ./
26
27# Optionally, specify how to launch the source code of your actor.
28# By default, Apify's base Docker images define the CMD instruction
29# that runs the Node.js source code using the command specified
30# in the "scripts.start" section of the package.json file.
31# In short, the instruction looks something like this:
32#
33# CMD npm start

INPUT_SCHEMA.json

1{
2  "title": "Actor input schema",
3  "description": "This is actor input schema",
4  "type": "object",
5  "schemaVersion": 1,
6  "properties": {
7    "accessToken": {
8      "title": "accessToken",
9      "type": "string",
10      "description": "accessToken",
11      "editor": "hidden",
12      "prefill": "yyPJFZUQupsAAAAAAAAAAaqbteq4MbCejyUDwz7mLtD3Xyw1_4DiFbysWj9sewGB"
13    },
14    "filePath": {
15      "title": "filePath",
16      "type": "string",
17      "description": "filePath",
18      "editor": "textarea"
19    },
20    "fileUrl": {
21      "title": "fileUrl",
22      "type": "string",
23      "description": "fileUrl",
24      "editor": "textarea"
25    }
26  },
27  "required": []
28}

apify.json

1{
2    "env": { "npm_config_loglevel": "silent" }
3}

main.js

1require('isomorphic-fetch');
2const Apify = require('apify');
3const request = require('request-promise');
4const Dropbox = require('dropbox').Dropbox;
5
6Apify.main(async () => {
7    const input = await Apify.getValue('INPUT');
8
9    if(!input.accessToken){throw new Error('Missing "accessToken" attribute in INPUT!');}
10    if(!input.filePath){throw new Error('Missing "filePath" attribute in INPUT!');}
11    if(!input.fileUrl && !input.fileContents && !input.fileBase64){
12        throw new Error('Missing "fileUrl", "fileContents" or "fileBase64" attribute in INPUT!');
13    }
14
15    const fileData = input.fileUrl ? (await request({
16        uri: input.fileUrl,
17        encoding: null
18    })) : (input.fileContents || Buffer.from(input.fileBase64, 'base64'));
19
20    const dbx = new Dropbox({ accessToken: input.accessToken });
21    // try to upload the file with retries
22    let lastError;
23    for (let i = 0; i < 4; i++) {
24        try {
25            const response = await dbx.filesUpload({path: input.filePath, contents: fileData, mode: 'overwrite'});
26            console.log(response)
27            return response;
28        } catch (e) {
29            lastError = e;
30            console.log(e)
31            await Apify.utils.sleep((i + 1) * 600);
32        }
33    }
34    throw lastError;
35});

package.json

1{
2    "name": "000000001",
3    "version": "0.0.1",
4    "description": "This is a boilerplate of an Apify actor.",
5    "main": "main.js",
6    "license": "Apache-2.0",
7    "dependencies": {
8        "apify": "^2.0.0",
9        "dropbox": "^4.0.1",
10        "isomorphic-fetch": "^2.2.1",
11        "request-promise": "^4.2.2"
12    },
13    "devDependencies": {
14        "@apify/eslint-config": "^0.1.3",
15        "eslint": "^7.0.0"
16    },
17    "scripts": {
18        "start": "node main.js",
19        "lint": "./node_modules/.bin/eslint ./src --ext .js,.jsx",
20        "lint:fix": "./node_modules/.bin/eslint ./src --ext .js,.jsx --fix",
21        "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
22    },
23    "author": "It's not you it's me"
24}
Developer
Maintained by Community
Categories