{"id":14978596,"url":"https://github.com/nestjs/azure-storage","last_synced_at":"2025-04-05T12:05:58.434Z","repository":{"id":37786760,"uuid":"192709413","full_name":"nestjs/azure-storage","owner":"nestjs","description":"Azure Storage module for Nest framework (node.js) ☁️","archived":false,"fork":false,"pushed_at":"2024-10-28T22:59:29.000Z","size":874,"stargazers_count":87,"open_issues_count":32,"forks_count":35,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T14:58:29.845Z","etag":null,"topics":["azure","azure-storage","cloud","javascript","nest","nestjs","nodejs","storage","typescript"],"latest_commit_sha":null,"homepage":"https://nestjs.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nestjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-19T10:17:25.000Z","updated_at":"2024-09-30T20:11:45.000Z","dependencies_parsed_at":"2024-01-30T23:49:27.014Z","dependency_job_id":"2e69f2be-3a66-4c74-afc5-c7b5c09c5c2e","html_url":"https://github.com/nestjs/azure-storage","commit_stats":{"total_commits":276,"total_committers":14,"mean_commits":"19.714285714285715","dds":0.2065217391304348,"last_synced_commit":"aaf086027269af0bdac647b671440762c527c4c2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Fazure-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Fazure-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Fazure-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Fazure-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nestjs","download_url":"https://codeload.github.com/nestjs/azure-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299829,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-storage","cloud","javascript","nest","nestjs","nodejs","storage","typescript"],"created_at":"2024-09-24T13:57:59.382Z","updated_at":"2025-04-05T12:05:58.396Z","avatar_url":"https://github.com/nestjs.png","language":"TypeScript","funding_links":["https://opencollective.com/nest","https://paypal.me/kamilmysliwiec"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo_text.svg\" width=\"320\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master\n[travis-url]: https://travis-ci.org/nestjs/nest\n[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux\n[linux-url]: https://travis-ci.org/nestjs/nest\n\n  \u003cp align=\"center\"\u003eA progressive \u003ca href=\"http://nodejs.org\" target=\"blank\"\u003eNode.js\u003c/a\u003e framework for building efficient and scalable server-side applications.\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@nestjs/core.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@nestjs/core.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@nestjs/core.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/nestjs/nest\"\u003e\u003cimg src=\"https://api.travis-ci.org/nestjs/nest.svg?branch=master\" alt=\"Travis\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/nestjs/nest\"\u003e\u003cimg src=\"https://img.shields.io/travis/nestjs/nest/master.svg?label=linux\" alt=\"Linux\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/nestjs/nest?branch=master\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5\" alt=\"Coverage\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/G7Qnnhy\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-online-brightgreen.svg\" alt=\"Discord\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#backer\"\u003e\u003cimg src=\"https://opencollective.com/nest/backers/badge.svg\" alt=\"Backers on Open Collective\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#sponsor\"\u003e\u003cimg src=\"https://opencollective.com/nest/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://paypal.me/kamilmysliwiec\"\u003e\u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-dc3d53.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/nestframework\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/nestframework.svg?style=social\u0026label=Follow\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n  \u003c!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)\n  [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)--\u003e\n\n## Description\n\n[Azure Storage](http://bit.ly/nest_azure-storage-blob) module for [Nest](https://github.com/nestjs/nest) framework (node.js)\n\n## Tutorial\n\nLearn how to get started with [Azure table storage for NestJS](https://trilon.io/blog/nestjs-nosql-azure-table-storage)\n\n## Before Installation\n\n1. Create a Storage account and resource ([read more](http://bit.ly/nest_new-azure-storage-account))\n1. In the [Azure Portal](https://portal.azure.com), go to **Dashboard \u003e Storage \u003e _your-storage-account_**.\n2. Note down the \"AccountName\", \"AccountKey\" obtained at **Access keys** and \"AccountSAS\" from **Shared access signature** under **Settings** tab.\n\n## (Recommended) Installation and automatic configuration\n\nUsing the Nest CLI:\n\n```bash\n$ nest add @nestjs/azure-storage\n```\n\n## Additional options\n\nYou can pass additional flags to customize the post-install schematic. For example, if your base application directory is different than `src`, use `--rootDir` flag:\n\n```bash\n$ nest add @nestjs/azure-storage --rootDir app\n```\n\nWhen requested, provide the `storageAccountName` and `storageAccountSAS` (see below).\n\nOther available flags:\n\n- `rootDir` - Application root directory, default: `src`\n- `rootModuleFileName` - the name of the root module file, default: `app.module`\n- `rootModuleClassName` - the name of the root module class, default: `AppModule`\n- `mainFileName` - Application main file, default: `main`\n- `skipInstall` - skip installing dependencies, default: `false`\n- `storageAccountName` (required) - The Azure Storage account name (see: http://bit.ly/azure-storage-account)\n- `storageAccountSAS` (required) - The Azure Storage SAS Key (see: http://bit.ly/azure-storage-sas-key).\n\n## (Option 2) Manual configuration\n\n1. Install the package using NPM:\n\n```bash\n$ npm i -S @nestjs/azure-storage\n```\n\n2. Create or update your existing `.env` file with the following content:\n\n```bash\n# See: http://bit.ly/azure-storage-sas-key\nAZURE_STORAGE_SAS_KEY=\n# See: http://bit.ly/azure-storage-account\nAZURE_STORAGE_ACCOUNT=\n```\n\n\u003e The SAS has the following format: `?sv=2018-03-28\u0026ss=bfqt\u0026srt=sco\u0026sp=rwdlacup\u0026se=2019-12-31T22:54:03Z\u0026st=2019-07-11T13:54:03Z\u0026spr=https,http\u0026sig=WmAl%236251oj11biPK2xcpLs254152H9s0%3D`\n\n3. **IMPORTANT: Make sure to add your `.env` file to your `.gitignore`! The `.env` file MUST NOT be versionned on Git.**\n\n4. Make sure to include the following call to your main file:\n\n```typescript\nif (process.env.NODE_ENV !== 'production') require('dotenv').config();\n```\n\n\u003e This line must be added before any other imports!\n\n5. Import the `AzureStorageModule` with the following configuration:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { AppController } from './app.controller';\nimport { AppService } from './app.service';\nimport { AzureStorageModule } from '@nestjs/azure-storage';\n\n@Module({\n  controllers: [AppController],\n  providers: [AppService],\n  imports: [\n    AzureStorageModule.withConfig({\n      sasKey: process.env['AZURE_STORAGE_SAS_KEY'],\n      accountName: process.env['AZURE_STORAGE_ACCOUNT'],\n      containerName: 'nest-demo-container',\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nIf you want to use asynchronous configuration options using factory or class,\n\n```typescript\nconst storageConfigFactory = async () =\u003e {\n  sasKey: process.env['AZURE_STORAGE_SAS_KEY'],\n  accountName: process.env['AZURE_STORAGE_ACCOUNT'],\n  containerName: 'nest-demo-container',\n};\n\n@Module({\n  controllers: [AppController],\n  providers: [AppService],\n  imports: [\n    AzureStorageModule.withConfigAsync({\n      useFactory: storageConfigFactory,\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n\u003e You may provide a default `containerName` name for the whole module, this will apply to all controllers withing this module. You can also provide (override) the `containerName` in the controller, for each route.\n\n## Story examples\n\n### Store a file using the default container name\n\n```typescript\nimport {\n  Controller,\n  Logger,\n  Post,\n  UploadedFile,\n  UseInterceptors,\n} from '@nestjs/common';\nimport { FileInterceptor } from '@nestjs/platform-express';\nimport {\n  AzureStorageFileInterceptor,\n  UploadedFileMetadata,\n} from '@nestjs/azure-storage';\n\n@Controller()\nexport class AppController {\n  \n  @Post('azure/upload')\n  @UseInterceptors(\n    AzureStorageFileInterceptor('file'),\n  )\n  UploadedFilesUsingInterceptor(\n    @UploadedFile()\n    file: UploadedFileMetadata,\n  ) {\n    Logger.log(`Storage URL: ${file.storageUrl}`, 'AppController');\n  }\n}\n```\n\n### Store a file using a specific container name\n\n```typescript\nimport {\n  Controller,\n  Logger,\n  Post,\n  UploadedFile,\n  UseInterceptors,\n} from '@nestjs/common';\nimport { FileInterceptor } from '@nestjs/platform-express';\nimport {\n  AzureStorageFileInterceptor,\n  UploadedFileMetadata,\n} from '@nestjs/azure-storage';\n\n@Controller()\nexport class AppController {\n  \n  @Post('azure/upload')\n  @UseInterceptors(\n    AzureStorageFileInterceptor('file', null, {\n      containerName: 'nest-demo-container-interceptor',\n    }),\n  )\n  UploadedFilesUsingInterceptor(\n    @UploadedFile()\n    file: UploadedFileMetadata,\n  ) {\n    Logger.log(`Storage URL: ${file.storageUrl}`, 'AppController');\n  }\n}\n```\n\n### Store a file using a custom file name\n\n```typescript\nimport {\n  Controller,\n  Logger,\n  Post,\n  UploadedFile,\n  UseInterceptors,\n} from '@nestjs/common';\nimport { FileInterceptor } from '@nestjs/platform-express';\nimport {\n  AzureStorageFileInterceptor,\n  AzureStorageService,\n  UploadedFileMetadata,\n} from '@nestjs/azure-storage';\n\n@Controller()\nexport class AppController {\n  constructor(private readonly azureStorage: AzureStorageService) {}\n  \n  @Post('azure/upload')\n  @UseInterceptors(FileInterceptor('file'))\n  async UploadedFilesUsingService(\n    @UploadedFile()\n    file: UploadedFileMetadata,\n  ) {\n    file = {\n      ...file,\n      originalname: 'foo-bar.txt',\n    };\n    const storageUrl = await this.azureStorage.upload(file);\n    Logger.log(`Storage URL: ${storageUrl}`, 'AppController');\n  }\n}\n```\n\n## Support\n\nNest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).\n\n## Stay in touch\n\n* Author - [Wassim Chegham](https://wassim.dev)\n* Website - [https://wassim.dev](https://wassim.dev/)\n* Twitter - [@manekinekko](https://twitter.com/manekinekko)\n\n## License\n\nNest is [MIT licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjs%2Fazure-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnestjs%2Fazure-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjs%2Fazure-storage/lists"}