000000001 avatar
000000001

Deprecated

Pricing

Pay per usage

Go to Store
000000001

000000001

Deprecated

Developed by

Widodo J P

Widodo J P

Maintained by Community

0.0 (0)

Pricing

Pay per usage

1

Total users

3

Monthly users

1

Last modified

4 years ago

.editorconfig

root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

.eslintrc

{
"extends": "@apify"
}

.gitignore

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

Dockerfile

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

INPUT_SCHEMA.json

{
"title": "Actor input schema",
"description": "This is actor input schema",
"type": "object",
"schemaVersion": 1,
"properties": {
"accessToken": {
"title": "accessToken",
"type": "string",
"description": "accessToken",
"editor": "hidden",
"prefill": "yyPJFZUQupsAAAAAAAAAAaqbteq4MbCejyUDwz7mLtD3Xyw1_4DiFbysWj9sewGB"
},
"filePath": {
"title": "filePath",
"type": "string",
"description": "filePath",
"editor": "textarea"
},
"fileUrl": {
"title": "fileUrl",
"type": "string",
"description": "fileUrl",
"editor": "textarea"
}
},
"required": []
}

apify.json

{
"env": { "npm_config_loglevel": "silent" }
}

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

{
"name": "000000001",
"version": "0.0.1",
"description": "This is a boilerplate of an Apify actor.",
"main": "main.js",
"license": "Apache-2.0",
"dependencies": {
"apify": "^2.0.0",
"dropbox": "^4.0.1",
"isomorphic-fetch": "^2.2.1",
"request-promise": "^4.2.2"
},
"devDependencies": {
"@apify/eslint-config": "^0.1.3",
"eslint": "^7.0.0"
},
"scripts": {
"start": "node main.js",
"lint": "./node_modules/.bin/eslint ./src --ext .js,.jsx",
"lint:fix": "./node_modules/.bin/eslint ./src --ext .js,.jsx --fix",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
"author": "It's not you it's me"
}