How to "require" a .yml file? - angularjs

I'm a beginner just trying to get the hang of elasticsearch with angular and have installed elasticsearch with the browserbuild here: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html
I was able to get elasticsearch loaded into angular as a module and was following along with this sample repo: https://github.com/spalger/elasticsearch-angular-example/blob/master/README.md
When I tried to run the cluster.state call, I received the following error: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
According to the sample repo, I need to configure the elasticsearch.yml file in order to allow CORS. I couldn't seem to find this file so I created my own but how do I now get my js files to "require" or "read" from it?

This is the configuration file for elasticsearch. It does not belong to the client.
Read about elasticsearch installation in their site and setup your development elasticsearch server to work against.
Good luck.

Related

Upload file is not working using AngularJS on lighttpd server

In my current project we are using lighttpd server. Here I am trying to upload the file. I am getting two Response Headers, first is with 301 Status code (Moved Permanently) and second is with 200 (OK).
But when I am checking in the folder I am not able to find any file (I mean no file uploaded).
I have tried both way to upload file as given links below:
http://jsfiddle.net/danialfarid/0mz6ff9o/135/
ngFileUpload
https://jsfiddle.net/JeJenny/ZG9re/
In both way I am getting the same response.
So here I have some sort of questions:
1) Is file upload is possible using AngularJS only? (No Server Side Script)
2) If possible, Is there any config problem with lighttpd?
Thanks !
Need Help...
The server side (or any web server) must be configured to handle POST and PUT requests. CGI, FastCGI, SCGI scripts can be written, or you can proxy to another backend. For simple file uploads, lighttpd also provides mod_webdav which you can configure (and protect with mod_auth) to allow you to upload files without having to write any server-side code.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModWebdav

Relay JS only on client side

I have developed a graphql server with laravel (https://github.com/Folkloreatelier/laravel-graphql). Now I would like to create a React application by using Relay. When I create my first component, then I receive the error:
Uncaught Error: Invariant Violation: RelayQL: Unexpected invocation at runtime. Either the Babel transform was not set up, or it failed to identify this call site. Make sure it is being used verbatim as Relay.QL.
I still googled the error and I recognized that I need to install the Babel Relay Plugin. But to include this plugin I have to specify a schema. But I still have specified this schema on server side, why do I need this also in client side? Is there any example how to implement this when a server is still implemented (external server, e.g. no NodeJS server).
Thank you for your advice.
The schema for your data on the server-side is required by babel-relay-plugin to do transpilation of Relay.QL fragments in Javscripts that will be delivered to the client-side. However, note that on your GraphQL server, you define the schema in Laravel GraphQL PHP classes, which you need to convert it into JSON format that babel-relay-plugin expects.
For example, I did a similar setup with Rails and graphql-ruby (https://github.com/nethsix/relay-on-rails).
Define the data schema on my server-side using graphql-ruby classes in app/graph directory
Convert the schema into a JSON file using a script lib/tasks/graphql.rake, which I then stash into app/assets/javascripts/relay/data/schema.json
Point to the schema.json in your babelRelayPlug.js file wherever it is (mine is in assets/javascripts/relay/utils/babelRelayPlugin.js)
For Rails, we can easily dump the graphql-ruby schema to json by just calling #to_json method. You may have similar methods in PHP.
I compared the difference between setting up Relay on a nodejs server, vs. a non-nodejs server using an illustration here if it helps (https://medium.com/#khor/relay-facebook-on-rails-8b4af2057152)

This resource can not be previewed at the moment. - CKAN

I’m running CKAN 2.2 on Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64).
I have uploaded a dataset to the CKAN instance. It has been uploaded successfully and can be downloaded as well. But when I try to preview the database I end up with below error.
This resource can not be previewed at the moment.
When I click on the “Click here for more information”, It says
Could not load preview: DataProxy returned an error (Request Error:
Backend did not respond after 10 seconds)
How can I fix this error?
The problem is that the data proxy (which is used to transform csv to
something that the data preview can understand) is a server on the
internet. Consequently the files you want to preview have to publicly
accessible from the internet as well. localhost is your own computer
which means that the dataproxy cannot access it. To solve this, wither put the file in the datastore using the datastorer or put the file on a server and provide the correct url.
.
This happens because the data proxy which is used to transform the
data into something we can preview with recline needs the files to be
accessible from the internet. The best solution is to store the data
in the datastore and then the preview will work.
Extracted from here & here
Sometimes you get the same message as the title question:
This resource can not be previewed at the moment.
But when you click on the “Click here for more information”, It says:
Could not load preview: DataProxy returned an error (Data transformation failed. error: An error occured while connecting to the server: DNS lookup failed for URL: http:///dataset/c3ce226b-73bd-4b06-9d1b-ffea13d5f770/resource/580fb05f-6d86-4748-aac7-560b904a208f/download/foo.csv)
In this case, probably the datapusher plugin is not working. First follow the instructions for datapusher in CKAN manual. If you already did this or you installed CKAN from a package, check the CKAN configuration in production.ini (development.ini) file. A small check list to solve the problem:
add datapusher in "ckan.plugins"
set "ckan.site_url"
set "ckan.datapusher.url"
check Apache/nginx server logs (/var/log/apache2/datapusher.*.log, /var/log/apache2/ckan_default*.log)
In my case, the issue was in my development.ini (or production.ini for you maybe) file where the lines for DataPusher's configuration were commented out with a # in the start of the line. Also, the ckan storage config line was also commented.
I uncommented those lines and it was solved.

authentication/http headers support in forge.file trigger.io module?

in the official trigger.io docs there seems to be no provision for custom http headers when it comes to the forge.file module. I need this so I can download files behind an http authentication scheme. This seems like an easy thing to add, if support is not already there.
any workarounds? any chance of a quick fix in the next update? I know I could use forge.request instead, but I'd like to keep a local copy (saveURL).
thanks
Unfortunately the file module just uses simple "download url" methods rather than a full HTTP request library, which makes it a fairly big task to add support for custom headers.
I've added a task to our backlog for this, but I don't have a timeframe for it being added.
Currently on iOS you can do basic auth by using urls in the form http://user:password#url.com in case that helps.
Maybe to avoid this you can configure your server differently, or have a proxy server in front that allows you to pass authentication details as get parameters?

Use HTTP POST to send file to IIS 7.5 virtual directory

Is it possible to allow HTTP clients to USE HTTP POST (with Content-Type: multipart/form-data) to upload image files to an IIS 7.5 virtual directory without writing server-side code?
Without server-side code, that is not possible. If HTTP POST is a requirement, you need to write code. Otherwise, configure an FTP site on your IIS installation.
If you really need HTTP, consider WebDav:
http://www.windowsnetworking.com/articles_tutorials/webdav-iis.html
http://learn.iis.net/page.aspx/350/installing-and-configuring-webdav-on-iis/
If you enable public write access in IIS with WebDAV, you can upload files using HTTP PUT requests.
More info.
There are lots of different WAYS you can handle this on the server side ... but all of them involve writing some kind of "code".
SUGGESTION:
Maybe a little asp.net script might be the ticket?
http://msdn.microsoft.com/en-us/library/aa479405.aspx

Resources