{"id":17241,"library":"grunt-http-upload","title":"Grunt HTTP Upload","description":"grunt-http-upload is a Grunt plugin designed for automating file uploads via POST or PUT HTTP requests directly within a Grunt build process. It allows developers to integrate file delivery to RESTful APIs or content management systems as part of their CI/CD or deployment workflows. The plugin currently sits at version 0.3.2, with its last update in 2016 primarily focused on replacing the deprecated `Restler` library with `Request` to ensure compatibility with newer Node.js versions (>=6.0.0). While Grunt itself has a less active development cadence compared to newer build tools, this plugin remains functional for existing Grunt-based projects needing straightforward HTTP file uploads. Its key differentiator is its deep integration into the Grunt ecosystem, simplifying what would otherwise require custom scripting or external `curl` commands.","status":"maintenance","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/DiscoverGrunt/grunt-http-upload","tags":["javascript","gruntplugin","grunt","http","upload","post","api","restler","curl"],"install":[{"cmd":"npm install grunt-http-upload","lang":"bash","label":"npm"},{"cmd":"yarn add grunt-http-upload","lang":"bash","label":"yarn"},{"cmd":"pnpm add grunt-http-upload","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, required to run the plugin as a Grunt task.","package":"grunt","optional":false}],"imports":[{"note":"Grunt plugins are loaded as tasks using `loadNpmTasks` within a `Gruntfile.js` or `Gruntfile.coffee`. They do not expose direct symbols for `import` or `require` in application code.","wrong":"import { http_upload } from 'grunt-http-upload';","symbol":"grunt.loadNpmTasks","correct":"grunt.loadNpmTasks('grunt-http-upload');"},{"note":"The `http_upload` task is configured within the `grunt.initConfig()` object, defining targets and options for file uploads. This is the primary way to interact with the plugin's functionality.","symbol":"http_upload task configuration","correct":"grunt.initConfig({\n  http_upload: { /* ... task configuration ... */ }\n});"}],"quickstart":{"code":"module.exports = function(grunt) {\n  grunt.initConfig({\n    pkg: grunt.file.readJSON('package.json'),\n    http_upload: {\n      your_target: {\n        options: {\n          url: 'https://api.example.com/upload?token=<%= pkg.apiKey %>', // Use template for API key or env var\n          method: 'POST',\n          rejectUnauthorized: true, // Typically set to true for production\n          headers: {\n            'Authorization': 'Bearer <%= process.env.UPLOAD_TOKEN ?? \"\" %>'\n          },\n          data: {\n            version: '<%= pkg.version %>',\n            environment: 'production'\n          },\n          onComplete: function(response) {\n            console.log('Upload complete. Server response:', response);\n          }\n        },\n        src: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip', // Source file to upload\n        dest: 'file' // Field name for the uploaded file on the API side\n      },\n    },\n  });\n\n  grunt.loadNpmTasks('grunt-http-upload');\n\n  // A default task to run the upload\n  grunt.registerTask('deploy', ['http_upload:your_target']);\n\n  // Example of a minimal package.json excerpt for the quickstart to be runnable:\n  // { \"name\": \"my-project\", \"version\": \"1.0.0\", \"apiKey\": \"YOUR_API_KEY\" }\n  // Remember to set UPLOAD_TOKEN environment variable or replace with actual token.\n};\n","lang":"javascript","description":"Demonstrates how to configure and run the `http_upload` Grunt task to upload a file to a specified API endpoint, including options for URL, method, headers, and data fields."},"warnings":[{"fix":"Ensure your Grunt environment is running on Node.js versions compatible with the `Request` library. Test upload configurations thoroughly after upgrading to v0.3.2 or later.","message":"Version 0.3.2 replaced the `Restler` HTTP client with `Request`. While this fixed deprecation warnings on Node.js >= 6.0.0, it constitutes a significant internal dependency change. Users upgrading from earlier versions might experience subtle behavioral differences if relying on specific `Restler` quirks.","severity":"breaking","affected_versions":">=0.3.2"},{"fix":"Always aim to use `rejectUnauthorized: true` (the default) and ensure your server's SSL certificate chain is correctly configured and trusted by Node.js. Update server certificates if necessary.","message":"The `rejectUnauthorized` option, when set to `false`, disables SSL certificate verification. This should only be used in development or controlled environments as it exposes the connection to man-in-the-middle attacks.","severity":"gotcha","affected_versions":">=0.1.6"},{"fix":"If multiple files need to be uploaded, configure separate `http_upload` task targets for each file or consider using a different plugin designed for multi-file operations.","message":"The plugin is designed to upload only a single file per task target. The `src` option expects a single file path string, not an array or a glob pattern for multiple files.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider migrating to a more modern build tool or finding an alternative Grunt plugin that uses a currently maintained HTTP client if active maintenance and security updates are critical for your project.","message":"The underlying `request` library, which `grunt-http-upload` depends on, has been deprecated since 2018 and is no longer actively maintained. While it may still function, it will not receive security patches or feature updates, posing a long-term risk.","severity":"deprecated","affected_versions":"0.3.2"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Add `grunt.loadNpmTasks('grunt-http-upload');` to your `Gruntfile.js` after defining `grunt.initConfig()`.","cause":"The Grunt plugin `grunt-http-upload` was installed but not loaded in the Gruntfile.","error":"Warning: Task \"http_upload\" not found. Use --force to continue."},{"fix":"Update `grunt-http-upload` to version `0.3.2` or higher using `npm install grunt-http-upload@latest --save-dev` to switch to the `request` library.","cause":"An older version of `grunt-http-upload` (<0.3.2) is being used with a Node.js version (typically >=6.0.0) where the `restler` dependency is no longer compatible or installed.","error":"Error: Cannot find module 'restler'"},{"fix":"Install `grunt` locally: `npm install grunt --save-dev`.","cause":"The `grunt` package, which is a peer dependency, is not installed in the project's `node_modules`.","error":"Error: Peer dependency \"grunt@>=0.4.0\" not installed."}],"ecosystem":"npm","meta_description":null}