I have installed strapi-provider-upload-aws-s3 and uploaded file to s3 successfully but is there any way we can change the link to cloudfront instead of using s3 ?
strapi": "3.0.0",
"strapi-provider-upload-aws-s3": "^3.0.0",
config/plugins.js
module.exports = ({ env }) => ({
upload: {
accessKeyId: "xxxxxxxxxx",
secretAccessKey: "xxxxxxxx",
region: "xxxxx",
params: {
Bucket: "xxxxx",
},
cloudfrontIsEnabled: 'Yes',
cloudfrontURL: "xxx.cloudfront.net",
}
}); (edited)
Found old issue but no luck in the new version
I don't think it's possible with current version of strapi and strapi-provider-upload-aws-s3
Your best bet is to fork the provider code, change the url here:
https://github.com/strapi/strapi/blob/master/packages/strapi-provider-upload-aws-s3/lib/index.js#L38
and add forked provider to your package.json file
"dependencies": {
...,
"strapi-provider-upload-aws-s3": "git+https://github.com/<YOUR_GITHUB_ACCOUNT>/strapi-provider-upload-aws-s3.git"
...
}
Related
var path = RNFetchBlob.fs.dirs.DocumentDir
RNFetchBlob
.config({
path: toFile,
addAndroidDownloads: {
useDownloadManager: true,
mime: 'text/plain',
description: 'Downloading...',
notification: false
}
})
.fetch('GET', fromUrl)
.progress((received, total) => {
})
I am using the above code for downloading files in the react-native. This is working fine in IOS. But not working with android.
I also tried
var path = RNFetchBlob.fs.dirs.DownloadDir
I also check with permission in Manifest
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
But nothing worked so Please let me know how can i resolve it. In the android and download files in the com.appname folder.
Thanks
I have a problem when uploading files in production with strapi. I have deployed strapi on Heroku and I am using the upload-provider-asws-s3 for files upload.
I created a settings.js file in extensions/upload/config with the following code :
if (process.env.NODE_ENV === 'production') {
module.exports = {
provider: "aws-s3",
providerOptions: {
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY,
region: "xxxxxxxxx",
params: {
Bucket: "xxxxxxxxx"
}
}
};
} else {
module.exports = {}
}
but when I connect to the strapi production admin and try to upload files, my s3 bucket won't load the files. I connected the same aws-s3 config to the development mode (just to test) and it worked perfectly. It is like heroku won't connect to aws-s3 but I don't get what I miss in my configuration to be able to upload files in the production mode.
Thank you all for your help!
version 4.3 of vue cli is in use.
I hope the external css file will be created separately after the build.
I have to use that file somewhere else.
**current result**
root
┗dist
┗css
┗app.dsfe23f.css
┗js
┗app.ds3fe23f.js
┗app.ds1fe23f.map
┗chunk-vendors.ds3fe23f.js
┗chunk-vendors.ds1fe23f.map
┗public
┗index.html
┗src
┗assets
┗css
┗GiftStyle.css
┗router
┗index.js
┗view
┗Home.vue
┗Gift.vue
┗App.vue
┗main.vue
**What I want**
root
┗dist
┗css
┗app.dsfe23f.css
┗GiftStyle.dsf231.css
┗js
┗app.ds3fe23f.js
┗app.ds1fe23f.map
┗chunk-vendors.ds3fe23f.js
┗chunk-vendors.ds1fe23f.map
┗public
┗index.html
┗src
┗assets
┗css
┗GiftStyle.css
┗router
┗index.js
┗view
┗Home.vue
┗Gift.vue
┗App.vue
┗main.vue
*****vue.config.js
const ExtractTextPlugin = require('mini-css-extract-plugin')
module.exports = {
chainWebpack: config => { config.plugin('extract-css').use(ExtractTextPlugin, [{
filename: 'css/[name].css',
allChunks: true
}])
},
configureWebpack:{
},
assetsDir: 'resources'
}
I am working with "strapi": "3.0.0-beta.18.2"
For your reference my package json looks like this:
"axios": "^0.19.2",
"knex": "^0.21.1",
"koa-router": "^9.0.1",
"objection": "^2.1.3",
"pg": "^8.0.3",
"sqlite3": "^4.1.1",
"strapi": "3.0.0-beta.18.2",
"strapi-admin": "3.0.0-beta.18.2",
"strapi-connector-bookshelf": "3.0.0-beta.18.2",
"strapi-plugin-content-manager": "3.0.0-beta.18.2",
"strapi-plugin-content-type-builder": "3.0.0-beta.18.2",
"strapi-plugin-email": "3.0.0-beta.18.2",
"strapi-plugin-upload": "3.0.0-beta.18.2",
"strapi-plugin-users-permissions": "3.0.0-beta.18.2",
"strapi-provider-upload-aws-s3": "^3.0.2",
"strapi-utils": "3.0.0-beta.18.2"
Uploading locally works perfect, but now I am trying to deploy to heroku.
When I try to upload a file I keep getting the following error:
The provider package isn't installed. Please run npm install strapi-provider-upload-aws-s3
I also get in the console, the following:
http://localhost:1337/content-manager/explorer/application::promotion.promotion/11 400 (Bad Request)
As you can see the package is already installed. I have checked and my app is running with productions settings.
Any idea what can be? this is giving me an strong headache.
I have also trying updating strapi version but it breaks my app.
I had the same problem than Alejandro Sanchez. The problem is that strapi is searching the provider name directly inside the upload object, not in upload.config and without the 'strapi-provider-upload' part in the name. This solution should work (replace gcp by aws depending on the case):
module.exports = ({ env }) => ({
upload: {
provider: 'google-cloud-storage',
providerOptions: {
bucketName: env("GCS_BUCKET_NAME"),
publicFiles: true,
uniform: true,
basePath: ""
},
},
});
Pay attention i removed the 'strapi-provider-upload' part in the config file. Same for aws, should be:
aws-s3 besides strapi-provider-upload-aws-s3
I have recently downloaded Spree 3.0.8 running on Amazon CLI Elastic Beanstalk.
I have encountered a problem that I can't work it out for 2 weeks.
My Spree commerce is able to upload the product image to S3 bucket using the following:
attachment_config = {
s3_credentials: {
access_key_id: "XXXXXXXXXXX",
secret_access_key: "gO7XXXXXXXXXX",
bucket: "sirac-products"
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
s3_protocol: "https",
bucket: "sirac-products",
url: "s3-website-ap-southeast-2.amazonaws.com",
styles: {
mini: "48x48>",
small: "100x100>",
product: "240x240>",
large: "600x600>"
},
path: "/:class/:id/:style/:basename.:extension",
default_url: "/:class/:id/:style/:basename.:extension",
default_style: "product"
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
The problem is the image links aren't correct both on admin and front side.
( The image link uses s3.amazonaws.com instead s3-ap-southeast-2.amazonaws.com).
Would anyone help me to issue this issue?
In your spree config file, try copying this code and modify according to you (ex: bucket name, key id and all... ) see if this works, and please make sure the region you are entering is correct. You can check that in s3 bucket as well
config/initializers/spree.rb
#--------------------------------------------
Spree.config do |config|
config.admin_interface_logo = "logo.png" #don copy this
attachment_config={
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
storage: :s3,
s3_headers: {"Cache-Control"=>"max-age=31557600"},
s3_protocol: "https",
bucket: ENV['ENV_BUCKET_NAME'],
s3_host_name: "s3-us-west-2.amazonaws.com", #your region
url: "url",
styles: {
mini: "60x76#",
small: "270x340#", #totally depends how you are going to keep the styles
product:"670x844#",
large: "700x881>"
},
path: "/spree/:class/:id/:style/:basename.:extension",
default_url: "/spree/products/:id/:style/:basename.:extension",
default_style: "product",
}
attachment_config.each do |key,value|
Spree::Image.attachment_definitions[:attachment][key.to_sym]=value
end
end
This worked for me, hope will do the same for you