voidlabs / mosaico

Mosaico - Responsive Email Template Editor
https://mosaico.io
GNU General Public License v3.0
1.7k stars 501 forks source link

how we can upload, uploaded images to aws s3 bucket #456

Closed ravir636 closed 2 years ago

ravir636 commented 6 years ago

i am trying to read images from uploaded json but get the Uncaugth error: error fs.readFileSync is not a funtion. i put this code inside localstorage.js file

var fs = require('fs'); var imagepath='C://Users/Administrator/Pictures/Screenshots/12353.png';

var base64str = base64_encode(imagepath); function base64_encode(file1) { var bitmap = fs.readFileSync(file1); return new Buffer(bitmap).toString('base64'); }

appreciate any help..

Hiswe commented 6 years ago

I think you have mixed server side code with client side. The localstorage.js is a client file and so can't access your file system.

If you try to read files from S3/filesystem this should be handled by your server. You should also provide a route to mosaico for accessing those images.

ravir636 commented 6 years ago

so how we can upload images to aws S3 bucket....

Hiswe commented 6 years ago

There is an official SDK for Amazon services available in NPM. The documentation is quite good so maybe you should give it a try :)

ravir636 commented 6 years ago

I mean how or what code we have to change on main.js file ,..app.use(/upload) already use so how we can get the route while image upload on block for AWS storage

Hiswe commented 6 years ago

in the front-end you should configure 2 things

{
  imgProcessorBackend: `url for resize`,
  fileuploadConfig: { /* configuration for upload */  } 
}

you can see that in this fork

in the backend you should handle those entry-points to use the S3

ravir636 commented 6 years ago

@Hiswe there is no server folder in my mosaico.. can you please tell how we can congifure in main.js file of backend

Hiswe commented 6 years ago

You will need to provide your own server logic. The server's file provided is only meant for a demo purpose.

So either you modify the existing file, or you come up with your own server (the server folder in the fork)

On Tue, May 29, 2018, 12:19 Ravi Rahangdale notifications@github.com wrote:

@Hiswe https://github.com/Hiswe there is no server folder in my mosaico.. can you please tell how we can congifure in main.js file of backend

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/voidlabs/mosaico/issues/456#issuecomment-392655601, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF3eRZ67qdNYMaHTc7nBU8vOpMIw9Szks5t3NpNgaJpZM4UPoYp .

ravir636 commented 6 years ago

@Hiswe can you provide simple solution so that we can modified existing files to storage in s3. like change in main.js or editer.js or server-config.js

Hiswe commented 6 years ago

Nope

On Tue, May 29, 2018, 13:03 Ravi Rahangdale notifications@github.com wrote:

can you provide simple solution so that we can modified existing files to storage in s3.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/voidlabs/mosaico/issues/456#issuecomment-392661935, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF3eTXgbbPo1T3JWZ_fNeuLaFkWL4UXks5t3OS8gaJpZM4UPoYp .

ravir636 commented 6 years ago

@Hiswe as you said change in existing so how we can.. if anything you can provide related to this its really great help for me.

Hiswe commented 6 years ago

https://github.com/goodenough/mosaico-backend

Also you should close this issue because it isn't related to Mosaico. The editor is a just front-end library which can be plugged to any server that have the right routes

ravir636 commented 6 years ago

@Hiswe its related to mosaico, when we are uploading file on blocks its automatically comes in /upload folder. so now i want to do same image store in s3 buckets. thats my point and help that i need.

ravir636 commented 6 years ago

@Hiswe can you please help out with these issue ..its really great help for me..

Hiswe commented 6 years ago

@ravir636 I've already helped you as much as I can:

Now you just need to do the thing :)