0

We are implementing a chatbot using FB Messenger. One of their requirements is that the customer have set of guides, documents (PDF, DocX), which they want to store in IBM Cloud. Whenever user asks for download of a guide then the chatbot should provide a link to the file, on clicking of which the file contents should be opened in a new window. Customer also has a requirement that their admin users should be provided a provision via Admin UI to upload new set of guides in future.

We are using Node.JS application. We are working on an approach of storing all the guides, documents within the Node.JS app and provide a relative location to those files in the chat interface.

We are adding files as static component:

'use strict';

var express = require('express'); 

app.use(express.static('./public'));

Then changing chat output string to have document URL to open it in new window successfully.

We want to upload the files as that's the requirement that user would like to upload the files through a UI in future.

Please provide pointers on uploading files as static components into the running application.

1 Answers1

0

Have you given this a read: http://upkarlidder.com/blog/posts/2017/bluemix-simple-static-site.html

Or this one: https://www.ibm.com/blogs/bluemix/2014/08/deploying-static-web-sites/

Nodejs magic to serve static site

app.use(express.static(__dirname + '/public'));

That single line in your app.js tells node.js where to fetch the static files from. You can just place your static site in the public directory and publish back to Bluemix using the next step

Rohit Shetty
  • 341
  • 2
  • 10
  • the snippet provided is a copy from one of the links. – Rohit Shetty Dec 30 '18 at 20:49
  • The links are from IBM and should be around long enough any way - so shouldnt be an issue. – Rohit Shetty Dec 30 '18 at 20:49
  • Thank You Rohit for your inputs. Could you please provide pointers on uploading files through UI into the cloud running application as static components. – prashanthmadduri Dec 31 '18 at 02:51
  • Prashanth, you should use object store. See https://www.altoros.com/blog/uploading-files-to-ibm-bluemix-object-storage-a-sample-app/ – Rohit Shetty Dec 31 '18 at 04:44
  • Thanks Rohit, does this Object storage is the only solution here, instead, can we directly upload the files into application's '/public' folder of cloud running application and retrieving whenever required. – prashanthmadduri Jan 01 '19 at 02:34
  • No, remember the application could be deployed To a different server every time and the files that are uploaded into the public folder might get lost when the application is redeployed. So you would want to use some sort of external storage and object storage is a great option. – Rohit Shetty Jan 01 '19 at 23:52
  • I think the post has answered your question - can you mark it as answered? – Rohit Shetty Jan 02 '19 at 00:23