Adding a storage service, '/container' not found in the explorer

568 views
Skip to first unread message

Nicole Chung

unread,
Sep 2, 2014, 12:00:43 PM9/2/14
to loopb...@googlegroups.com
I did:

npm install loopback-storage-service --save

In my package.json I then see:
 "loopback-storage-service": "^1.0.4",

And the module is in my node_modules folder.

Then in my server.js, before I start my server, I added:

var ds = loopback.createDataSource({
    connector: require('loopback-storage-service'),
    provider: 'filesystem',
    root: '../tmp/storage'
});

var container = ds.createModel('container');

app.model(container);

However, when I start the server, I am not seeing the "container" endpoint in the loopback explorer.


Sumitha Nathan

unread,
Sep 2, 2014, 2:54:48 PM9/2/14
to loopb...@googlegroups.com

I assume you are using LoopBack 2.0. Note that the module name changed in 2.0 loopback-storage-service - > loopback-component-storage

the line for connector should be

connector: require('loopback-component-storage'),

http://docs.strongloop.com/display/LB/Storage+service

Andrew B

unread,
Sep 2, 2014, 3:30:09 PM9/2/14
to loopb...@googlegroups.com
I don't see what I'm looking for in the short documentation.  Is there a way to get a direct link to the file on third party storage?

How does loopback handle reducing bandwidth on the node server when uploading and downloading to a third party storage provider?  Does a download request redirect directly to Amazon or does the traffic proxy through the node server?  I ask because the point of using something like S3 is to reduce the load on the application server.

Thanks!

Nicole Chung

unread,
Sep 2, 2014, 4:21:32 PM9/2/14
to loopb...@googlegroups.com
Good points on that, I'm interested in finding out more too.

So I updated my package.json, uninstalled loopback-storage-service, and installed loopback-component-storage. This returns a response correctly at:


But does not show up at


That being said, I have enough to work with...I just can't view it in the explorer.

Charles Naccio

unread,
Oct 9, 2014, 12:24:09 PM10/9/14
to loopb...@googlegroups.com
Someone correct me if I'm, wrong, but from what I've figured out you have to setup your storage provider one directory level up in order to download this file through the API. Alternatively you can create a directory within containers, and then place the files you need to download within this newly created directory. For example: http://localhost:3000/api/containers/newDirectory/download/file.txt Think of containers as the root directory, but you cannot download files within the root directory; you need to create folders (aka containers) within your root directory. Let me know if you need anymore help getting this working.

Ran Regev

unread,
Feb 12, 2015, 5:04:15 AM2/12/15
to loopb...@googlegroups.com

I have the same problem - I get responses from /api/ but I don't see the models in /explorer/

Ran.

Ran Regev

unread,
Feb 12, 2015, 6:11:48 AM2/12/15
to loopb...@googlegroups.com


Root cause found.

Thanks to this help I understood that this is a timing problem.

The explorer is loaded before the models are present.
I use discoverAndBuildModels so I have to wait till it wakes all over the database.

I solved it by doing this:

1. I moved explorer.js from server/boot to server.
2. I added setTimeout call in server.js like this:
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname);

setTimeout( function(){
    require( './explorer' )(app)
    } , 5000 ); 
    

app.start = function() {
// start the web server
  return app.listen(function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
  });
};



Now Explorer is loaded after 5 seconds, when all models are ready.



Ran.
Reply all
Reply to author
Forward
0 new messages