{"_id":"@edwardwangxy/s3-files-adapter","name":"@edwardwangxy/s3-files-adapter","dist-tags":{"latest":"1.6.2"},"versions":{"1.6.2":{"name":"@edwardwangxy/s3-files-adapter","version":"1.6.2","description":"AWS S3 adapter for parse-server","main":"index.js","scripts":{"pretest":"npm run lint","test":"NODE_ENV=test NODE_CONFIG_DIR=./spec/config istanbul cover -x **/spec/** jasmine --captureExceptions","lint":"eslint --cache ./","lint:fix":"eslint --fix --cache ./"},"repository":{"type":"git","url":"git+https://github.com/parse-community/parse-server-s3-adapter.git"},"keywords":["parse-server","AWS","S3"],"author":{"name":"Parse"},"license":"ISC","bugs":{"url":"https://github.com/parse-community/parse-server-s3-adapter/issues"},"homepage":"https://github.com/parse-community/parse-server-s3-adapter#readme","dependencies":{"aws-sdk":"2.907.0"},"devDependencies":{"parse":"3.3.1","codecov":"3.8.3","config":"3.3.2","eslint":"7.13.0","eslint-config-airbnb-base":"14.2.1","eslint-plugin-import":"2.22.1","istanbul":"0.4.5","jasmine":"3.5.0","parse-server-conformance-tests":"1.0.0"},"gitHead":"d36a003257faafc2f7835bddd27b16f8244967b3","_id":"@edwardwangxy/s3-files-adapter@1.6.2","_nodeVersion":"19.1.0","_npmVersion":"9.1.2","dist":{"integrity":"sha512-0xLjoTFijIgk9Asz0t9VC1lpPkt+imXTn0z4hIZa4wUu4pIPnWSLmJgw37eWYxzF99A8b82/diZKsmM3tE+a7w==","shasum":"090b894c299e7a2f50ad12412ea9e3d8022f6398","tarball":"https://registry.npmjs.org/@edwardwangxy/s3-files-adapter/-/s3-files-adapter-1.6.2.tgz","fileCount":15,"unpackedSize":59153,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBWBlzEFU37xQgsjN49AAYRVhuFse6phm4hIvvE4ZcpsAiEA5/3vhxGLqR3a9qMgxygj/suVq1YRhCyvwfRKojpTFeI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkL28IACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqb7Q/+I1x00nr7Zouk+f1ImoR2Op5IAWWFEzkE9nr3OPi5KOj7CLOb\r\nC599QbC+4rdINo1EMPBBjRRqDAth0styNpsQ+wHujDQ4PJGqF9b4+Q3Z7yWw\r\npA1Cq1Wpz0TxZlrKKUfmzrVMUb+nfKB8y6SZH0Em438EuC1BEBI5DeNe4dvT\r\niDVueOWtXNAOXoE9RksuhxOBv6fJwVDrE6Yqd8/grcyJ/Ttu6fe6dlhbF+SW\r\nqFG4whE3KqMEF+VgqwSFAqYrxpqAmcpFKnlIZwvq9yyCUr9fexuhCrO0EQep\r\nDiO+uR6VensR5BtPKZPbnEHPuc/Bi4NpSuVtMWNdoK1MDQSCB0hhHeHB1axf\r\ntYIReHwQVLL0HCU8ehIqvN5D3SB966CRHJPpKec/8qEanlZdF++9G+zkcmVT\r\n0+IdXAVpYHN/jzWkFK1fqTEepDln/67eaOvhX4qJVvCoBHFBwH69Gtaa82yC\r\nGdxyQOZtbZNuo+vKxmD4ARn2d+SiOy6Ccfg952oSDOjE1LbFZqNd4dDgQIaW\r\nmdCORcjGgiFOcPsBTIm60VgpEN17wJL2dXvvbw6QmdZwTmFSS/ZGZ7HVMaJe\r\n9Sin6TMun/JkDDFjjsWD0MJJ4gdBpxDRIbA1PN9BWDEe4/s+/IN1BSPfEMez\r\nyVaSbWU8JBxzp1ZefXWGoyI7vaBxdMD5r8s=\r\n=2LJC\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"edwardwangxy","email":"edwardwangxy@gmail.com"},"directories":{},"maintainers":[{"name":"edwardwangxy","email":"edwardwangxy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/s3-files-adapter_1.6.2_1680830216701_0.940887214631948"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-07T01:16:56.651Z","1.6.2":"2023-04-07T01:16:56.944Z","modified":"2023-04-07T01:16:57.119Z"},"maintainers":[{"name":"edwardwangxy","email":"edwardwangxy@gmail.com"}],"description":"AWS S3 adapter for parse-server","homepage":"https://github.com/parse-community/parse-server-s3-adapter#readme","keywords":["parse-server","AWS","S3"],"repository":{"type":"git","url":"git+https://github.com/parse-community/parse-server-s3-adapter.git"},"author":{"name":"Parse"},"bugs":{"url":"https://github.com/parse-community/parse-server-s3-adapter/issues"},"license":"ISC","readme":"# parse-server-s3-adapter\n<a href=\"https://www.npmjs.com/package/@parse/s3-files-adapter\"><img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@parse/s3-files-adapter.svg?style=flat\"></a>\n[![Known Vulnerabilities](https://snyk.io/test/github/parse-community/parse-server-s3-adapter/badge.svg?targetFile=package.json)](https://snyk.io/test/github/parse-community/parse-server-s3-adapter?targetFile=package.json)\n[![codecov.io](https://codecov.io/github/parse-community/parse-server-s3-adapter/coverage.svg?branch=master)](https://codecov.io/github/parse-community/parse-server-s3-adapter?branch=master)\n<a href=\"https://github.com/parse-community/parse-server-s3-adapter/actions?query=workflow%3Aci+branch%3Amaster\">\n  <img alt=\"Build status\" src=\"https://github.com/parse-community/parse-server-s3-adapter/workflows/ci/badge.svg?branch=master\">\n</a>\n\nparse-server adapter for AWS S3\n\n# installation\n\n`npm install --save @parse/s3-files-adapter`\n\n# AWS Credentials\n\n## Deprecation Notice -- AWS Credentials\n *the ability to explicitly pass credentials to this adapter is deprecated and will be removed in a future release.*\n\nYou may already be compatible with this change.  If you have not explicitly set an `accessKey` and `secretKey` and you have configured the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, then you're all set and this will continue to work as is.\n\nIf you explicitly configured the environment variables `S3_ACCESS_KEY`\n`S3_SECRET_KEY`\n\n*OR*\n\nIf you explicitly configured the `accessKey` and `secretKey` in your adapter configuration, then you'll need to...\n\nFor non AWS hosts:\n\n*  Run `aws configure` in a terminal which will step you through configuring credentials for the AWS SDK and CLI\n\nFor an AWS host:\n\n*  Ensure that the role that your host is running as has permissions for your s3 bucket\n\n*Then*\n\n*  remove the `accessKey` and `secretKey` from your configuration\n\nIf for some reason you really need to be able to set the key and secret explicitly, you can still do it using `s3overrides` as described below and setting `accessKeyId` and `secretAccessKey` in the `s3Overrides` object.\n\n# Deprecated Configuration\nAlthough it is not recommended, AWS credentials can be explicitly configured through an options\nobject, constructor string arguments or environment variables ([see below](#using-a-config-file)).\nThis option is provided for backward compatibility and will be removed in the forthcoming version 2.0 of this adapter.\n\nThe preferred method is to use the default AWS credentials pattern.  If no AWS credentials are explicitly configured, the AWS SDK will look for credentials in the standard locations used by all AWS SDKs and the AWS CLI. More info can be found in [the docs](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#config-settings-and-precedence).  For more information on AWS best practices, see [IAM Best Practices User Guide](http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html).\n\n# Usage with Parse Server\n\n### Parameters\n\n*(This list is still incomplete and in the works, in the meantime find more descriptions in the chapters below.)*\n\n| Parameter | Optional | Default value | Environment variable | Description |\n|-----------|----------|---------------|----------------------|-------------|\n| `fileAcl` | yes | `undefined` | S3_FILE_ACL | Sets the [Canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) of the file when storing it in the S3 bucket. Setting this parameter overrides the file ACL that would otherwise depend on the `directAccess` parameter. Setting the value `'none'` causes any ACL parameter to be removed that would otherwise be set. |\n\n### Using a config file\n\n```\n{\n  \"appId\": 'my_app_id',\n  \"masterKey\": 'my_master_key',\n  // other options\n  \"filesAdapter\": {\n    \"module\": \"@parse/s3-files-adapter\",\n    \"options\": {\n      \"bucket\": \"my_bucket\",\n      // optional:\n      \"region\": 'us-east-1', // default value\n      \"bucketPrefix\": '', // default value\n      \"directAccess\": false, // default value\n      \"fileAcl\": null, // default value\n      \"baseUrl\": null, // default value\n      \"baseUrlDirect\": false, // default value\n      \"signatureVersion\": 'v4', // default value\n      \"globalCacheControl\": null, // default value. Or 'public, max-age=86400' for 24 hrs Cache-Control\n      \"ServerSideEncryption\": 'AES256|aws:kms', //AES256 or aws:kms, or if you do not pass this, encryption won't be done\n      \"validateFilename\": null, // Default to parse-server FilesAdapter::validateFilename.\n      \"generateKey\": null // Will default to Parse.FilesController.preserveFileName\n    }\n  }\n}\n```\n***Note*** By default Parse.FilesController.preserveFileName will prefix all filenames with a random hex code.   You will want to disable that if you enable it here or wish to use S3 \"directories\".\n\n### using environment variables\n\nSet your environment variables:\n\n```\nS3_BUCKET=bucketName\n```\n\nthe following optional configuration can be set by environment variable too:\n\n```\nS3_SIGNATURE_VERSION=v4\n```\n\nAnd update your config / options\n\n```\n{\n  \"appId\": 'my_app_id',\n  \"masterKey\": 'my_master_key',\n  // other options\n  \"filesAdapter\": \"@parse/s3-files-adapter\"\n}\n```\n\n\n### passing as an instance\n```\nvar S3Adapter = require('@parse/s3-files-adapter');\n\nvar s3Adapter = new S3Adapter('accessKey',\n                  'secretKey', bucket, {\n                    region: 'us-east-1'\n                    bucketPrefix: '',\n                    directAccess: false,\n                    baseUrl: 'http://images.example.com',\n                    signatureVersion: 'v4',\n                    globalCacheControl: 'public, max-age=86400',  // 24 hrs Cache-Control.\n                    validateFilename: (filename) => {\n                      if (filename.length > 1024) {\n                         return 'Filename too long.';\n                       }\n                       return null; // Return null on success\n                    },\n                    generateKey: (filename) => {\n                        return `${Date.now()}_${filename}`; // unique prefix for every filename\n                    }\n                  });\n\nvar api = new ParseServer({\n\tappId: 'my_app',\n\tmasterKey: 'master_key',\n\tfilesAdapter: s3adapter\n})\n```\n**Note:** there are a few ways you can pass arguments:\n\n```\nS3Adapter(\"bucket\")\nS3Adapter(\"bucket\", options)\nS3Adapter(\"key\", \"secret\", \"bucket\") -- Deprecated, see notice above\nS3Adapter(\"key\", \"secret\", \"bucket\", options) -- Deprecated, see notice above\nS3Adapter(options) // where options must contain bucket.\nS3Adapter(options, s3overrides)\n```\nIf you use the last form, `s3overrides` are the parameters passed to [AWS.S3](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property).\n\nIn this form if you set `s3overrides.params`, you must set at least `s3overrides.params.Bucket`\n\nor with an options hash\n\n```\nvar S3Adapter = require('@parse/s3-files-adapter');\n\nvar s3Options = {\n  \"bucket\": \"my_bucket\",\n  // optional:\n  \"region\": 'us-east-1', // default value\n  \"bucketPrefix\": '', // default value\n  \"directAccess\": false, // default value\n  \"baseUrl\": null // default value\n  \"signatureVersion\": 'v4', // default value\n  \"globalCacheControl\": null, // default value. Or 'public, max-age=86400' for 24 hrs Cache-Control\n  \"validateFilename\": () => null, // Anything goes!\n  \"generateKey\": (filename) => filename,  // Ensure Parse.FilesController.preserveFileName is true!\n}\n\nvar s3Adapter = new S3Adapter(s3Options);\n\nvar api = new ParseServer({\n  appId: 'my_app',\n  masterKey: 'master_key',\n  filesAdapter: s3Adapter\n})\n```\n### Usage with Digital Ocean Spaces\n\n```\nvar S3Adapter = require(\"@parse/s3-files-adapter\");\nvar AWS = require(\"aws-sdk\");\n\n//Configure Digital Ocean Spaces EndPoint\nconst spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);\nvar s3Options = {\n  bucket: process.env.SPACES_BUCKET_NAME,\n  baseUrl: process.env.SPACES_BASE_URL,\n  region: process.env.SPACES_REGION,\n  directAccess: true,\n  globalCacheControl: \"public, max-age=31536000\",\n  bucketPrefix: process.env.SPACES_BUCKET_PREFIX,\n  s3overrides: {\n    accessKeyId: process.env.SPACES_ACCESS_KEY,\n    secretAccessKey: process.env.SPACES_SECRET_KEY,\n    endpoint: spacesEndpoint\n  }\n};\n\nvar s3Adapter = new S3Adapter(s3Options);\n\nvar api = new ParseServer({\n  databaseURI: process.env.DATABASE_URI || \"mongodb://localhost:27017/dev\",\n  cloud: process.env.CLOUD_CODE_MAIN || __dirname + \"/cloud/main.js\",\n  appId: process.env.APP_ID || \"myAppId\",\n  masterKey: process.env.MASTER_KEY || \"\",\n  serverURL: process.env.SERVER_URL || \"http://localhost:1337/parse\",\n  logLevel: process.env.LOG_LEVEL || \"info\",\n  allowClientClassCreation: false,\n  filesAdapter: s3Adapter,\n  }\n});\n```\n\n### Adding Metadata and Tags\n\nUse the optional options argument to add [Metadata](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-object-metadata.html) and/or [Tags](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-object-tags.html) to S3 objects\n\n```\n\n\nconst S3Adapter = require('@parse/s3-files-adapter');\n\nconst s3Options = {}; // Add correct options\nconst s3Adapter = new S3Adapter(s3Options);\n\nconst filename = 'Fictional_Characters.txt';\nconst data = 'That\\'s All Folks!';\nconst contentType = 'text/plain';\nconst tags = {\n  createdBy: 'Elmer Fudd',\n  owner: 'Popeye'\n};\nconst metadata = {\n  source: 'Mickey Mouse'\n};\nconst options = { tags, metadata };\ns3Adapter.createFile(filename, data, contentType, options);\n\n```\n\n**Note:** This adapter will **automatically** add the \"x-amz-meta-\" prefix to the beginning of metadata tags as stated in [S3 Documentation](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-object-metadata.html).","readmeFilename":"README.md"}