strapi/docs/.vuepress/dist/assets/js/55.7faca13f.js

1 line
20 KiB
JavaScript
Raw Normal View History

2018-10-05 17:24:17 +02:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[55],{184:function(t,s,a){"use strict";a.r(s);var n=a(0),e=Object(n.a)({},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"content"},[t._m(0),t._v(" "),t._m(1),t._v(" "),t._m(2),t._v(" "),t._m(3),t._v(" "),t._m(4),t._v(" "),t._m(5),t._v(" "),t._m(6),t._v(" "),t._m(7),t._v(" "),t._m(8),t._v(" "),a("p",[t._v("To add a new file attribute in your models, it's like adding a new association. In the first example, you will be able to upload and attach one file to the avatar attribute. Whereas, in our second example, you can upload and attach multiple pictures to the product.")]),t._v(" "),t._m(9),t._v(" "),t._m(10),t._m(11),t._v(" "),t._m(12),t._m(13),t._v(" "),t._m(14),t._v(" "),t._m(15),t._m(16),t._v(" "),t._m(17),t._m(18),t._v(" "),t._m(19),t._v(" "),t._m(20),t._m(21),t._m(22),t._v(" "),t._m(23),t._m(24),t._v(" "),a("p",[t._v("By default Strapi provides a local file upload system. You might want to upload your files on AWS S3 or another provider.")]),t._v(" "),a("p",[t._v("To install a new provider run:")]),t._v(" "),t._m(25),t._m(26),t._v(" "),t._m(27),t._v(" "),a("p",[t._v("Check all community providers available on npmjs.org - "),a("a",{attrs:{href:"https://www.npmjs.com/search?q=strapi-upload-",target:"_blank",rel:"noopener noreferrer"}},[t._v("Providers list"),a("OutboundLink")],1)])])},[function(){var t=this.$createElement,s=this._self._c||t;return s("h1",{attrs:{id:"file-upload"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#file-upload","aria-hidden":"true"}},[this._v("#")]),this._v(" File Upload")])},function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"warning custom-block"},[s("p",{staticClass:"custom-block-title"},[this._v("WARNING")]),this._v(" "),s("p",[this._v("This feature requires the Upload plugin (installed by default).")])])},function(){var t=this.$createElement,s=this._self._c||t;return s("p",[this._v("Thanks to the plugin "),s("code",[this._v("Upload")]),this._v(", you can upload any kind of files on your server or externals providers such as AWS S3.")])},function(){var t=this.$createElement,s=this._self._c||t;return s("h2",{attrs:{id:"usage"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#usage","aria-hidden":"true"}},[this._v("#")]),this._v(" Usage")])},function(){var t=this.$createElement,s=this._self._c||t;return s("p",[this._v("The plugin exposes a single route "),s("code",[this._v("POST /upload")]),this._v(" to upload one or multiple files in a single request.")])},function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"warning custom-block"},[s("p",{staticClass:"custom-block-title"},[this._v("WARNING")]),this._v(" "),s("p",[this._v("Please send the request using multipart/form-data encoding")])])},function(){var t=this.$createElement,s=this._self._c||t;return s("p",[s("strong",[this._v("Parameters")])])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("ul",[a("li",[a("code",[t._v("files")]),t._v(": The file(s) to upload. The value(s) can be a Buffer or Stream.")]),t._v(" "),a("li",[a("code",[t._v("refId")]),t._v(": (optional): The ID of the entry which the file(s) will be linked to.")]),t._v(" "),a("li",[a("code",[t._v("ref")]),t._v(": (optional): The name of the model which the file(s) will be linked to (see more below).")]),t._v(" "),a("li",[a("code",[t._v("source")]),t._v(": (optional): The name of the plugin where the model is located.")]),t._v(" "),a("li",[a("code",[t._v("field")]),t._v(": (optional): The field of the entry which the file(s) will be precisely linked to.")])])},function(){var t=this.$createElement,s=this._self._c||t;return s("h2",{attrs:{id:"models"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#models","aria-hidden":"true"}},[this._v("#")]),this._v(" Models")])},function(){var t=this.$createElement,s=this._self._c||t;return s("p",[s("strong",[this._v("Path —")]),this._v(" "),s("code",[this._v("User.settings.json")]),this._v(".")])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return