How to serve mp4 from bluemix application - ibm-cloud

I have a bluemix J2EE application that uses several mp4 video clips. The video's are present on the server, but they fail to load. The mp4 player shows "loading" but never displays the video. They are working properly from a locally deployed Tomcat instance, just not from the Bluemix deployment. I suspect there is a supported content type configuration somewhere that needs to be updated to include .mp4 but I'm not sure where that would be. Any help appreciated.

I would highly encourage not to host any large files inside of your app in Bluemix. I would highly encourage you to look at a CDN or an object storage service such as the one in Bluemix or Openstack Swift. The reasoning behind this is that there is a file size limit on your application. The limit is on log files, the middleware (the runtime, node or java or etc), and the app code itself. Having large files in your app fills this limit up quicker. Currently the limit is 1GB and this is Cloud Foundry imposed.

I just hacked up a very simple WAR to test this out. Things are working fine for me (both local Liberty deployment and Bluemix deployment). I am not sure how you have your things configured, but here's my source:
WebContent/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
Basic HTML file
<p>Basic Servlet</p>
<p>Basic MP4</p>
<p>Basic MP3</p>
<p>Basic JPEG</p>
</body>
</html>
The basicServlet, mp4, mp3 and jpeg are all peer files in WebContent.
The basicServlet is annotated (no web.xml):
package net.wasdev.sample;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
#WebServlet("/basicServlet")
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Basic Servlet at: ").append(request.getContextPath());
}
}
Are you able to access these files directly? I am able to access them directly in both local Liberty and Bluemix. I am not using any embedded video because if the file can be served up then the rest is just the embedded video player.

Check the mp4 files path, and the content type returned on the header when requesting the mp4 files. If wrong set it when returning the files.
I suggest you to use html5 video tag setting the content correctly.
If it is indefinitely loading I suspect that the mp4 file path is wrong.
If you wish, paste your site URL, we could check what could be wrong

Related

How to export static HTML from Svelte without Surge or Vercel?

I want to publish my Svelte web app to GitHub pages and based my application on the template https://github.com/sveltejs/template. When I run npm run build, public/build/bundle.js is created but no index.html. All the tutorials I found talk about how to deploy Sapper projects, or to use external tools like Vercel and Surge, but is it possible to just build Svelte without any external tools? All I want is a static HTML page that I can copy to GitHub pages.
Edit: See the accepted answer for the general approach, however for non-root-directory-deployment, you still need to make the paths relative. I created a pull request at https://github.com/sveltejs/template/pull/239.
In svelte, index.html is a static file which will import your bundle.js and run it.
index.html is located at /public/index.html while your bundle.js is located at /public/build/bundle.js
in svelte template, index.html imports /build/bundle.js using a script tag to initialize the application.
while deploying, you just need to upload the whole /public folder and everything should be operational.

javascript library not loaded in ionic

Im including the google cast external javascript library. When I run with ionic serve it works good, but when I run the app in the phone, the library is not loaded. Debugging can see that :
https://cdn-enterprise.discourse.org/ionicframework/uploads/default/original/3X/a/d/ad4c985f45c1c538bdfbfbb02d10141b6929e1d5.png
The "http" is replaced by "file"!
I tried to include the libraries with that code:
script src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1">
and with type="text/javascript" added; but all codes replaces http by file, and the library is not loaded.
Any suggestions?
When you run the app do not add cdn files starting with "//:", add them like "http://".
If its possible download those files and keep them in directory, after that give directory path to file.
e.g. <script type="text/javascript" src="assets/js/library.js">

Serving single page React app from Google Cloud Storage

I am trying to serve a React app from Google Cloud Storage. I built the React project and uploaded the contents of the build/ directory to Google Cloud Storage. I made sure every file inside is publicly accessible. However when I go to my Google Cloud bucket link http://storage.googleapis.com/BUCKET_NAME/, I get some XML about a permission error:
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Anonymous users does not have storage.objects.list access to bucket BUCKET_NAME.
</Details>
</Error>
Then, I tried to navigate to the URL http://storage.googleapis.com/BUCKET_NAME/index.html, which brings up a blank page. In the JS console, there are errors:
index.html:1 GET http://storage.googleapis.com/static/css/main.9a0fe4f1.css
index.html:1 GET http://storage.googleapis.com/static/js/main.871fec8f.js
These errors look like the BUCKET_NAME is not in the URL that was fetched. However, my built index.html is referencing them relatively, as so:
<script type="text/javascript" src="/static/js/main.871fec8f.js"></script>
I'm not sure what's going on, there are two issues. First is that index.html is not the default served page when going to the bucket URL. Second issue is that the relative paths don't seem to be resolving the right URL. Any help is appreciated.
This was a problem on my end. This method should work.

Play framework bootstrap images not available in production work in dev

I added Bootstrap to my Play 2.1 application. After adding the following routes, it works well in development:
GET /img/glyphicons-halflings.png controllers.Assets.at(path="/public", file="/images/bootstrap/glyphicons-halflings.png")
GET /img/glyphicons-halflings-white.png controllers.Assets.at(path="/public", file="/images/bootstrap/glyphicons-halflings-white.png")
This works fine in develop mode, but when I package the application using "dist" in play console, the glyphicons aren't available. What could possibly be causing that?
I also ran a jar xf on my the application's snapshot jar and can verify the images are there and are in the same layout as they are when I run play run locally.
All you need to use Bootstrap is unzip it into public/bootstrap/ folder and then just include it via Bootstrap's CSS in your view (you don't need to create separate routes(s) for glyphicons etc) while it's ready to use package, just don't move its pieces to folders proposed by Play docs and keep them in original structure:
<link rel="stylesheet" type="text/css" href='#routes.Assets.at("bootstrap/css/bootstrap.css")'>

Create and publish a static web project in Eclipse

when I tried to create and publish a static web project in eclipse I got: "Error copying file index.html: No such file or directory"
My environment: SuSE 12.2, Eclipse Indigo Release 2, Apache2 2.2.22,
This is what I did to create the project:
1) Create new Server
Basic, HTTP Server
Publishing Directory: /srv/www/htdocs
Enable publishing to this server: true
2) Create Project
New -> Static Web Project
Project Name: Simplepage
Target Runtime: HTTP Server (from 1)
Default Configuration
Content root: Simplepage
Web content folder name: WebContent
3) Create very simple page
Create new HTML file
Parent folder: Simplepage/WebContent
Name: index.html
Content:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
<title>Insert title here</title>
</head>
<body>
Test
</body>
</html>
4) Start Project
Right Click on Project Name -> Run as -> Run on Server
Here I got the error message mentioned above.
At this point there is a new folder /srv/www/htdocs/Simplepage created but has no content.
Later I made a test with the following configuration:
Change publishing directory to: "/srv/www/htdocs/XY"
Start Project gives error: "Access forbidden! You don't have permission to access the requested directory..."
At this time there is a new directory created: /srv/www/htdocs/XY/Simplepage containing the file index.html.
The window in eclipse is showing the path http://localhost/Simplepage/. When I change this manually to http://localhost/XY/Simplepage/ the newly created page is shown.
I don't understand this behaviour. Can someone explain this?
You have installed Apache2 server on your home computer, with the publishing directory /srv/www
Note that Apache2 runs on its own user (on my Ubuntu it is www-data). Apache's publishing directory /srv/www is normally owned by Apache's user.
You have also directed HTTP Server of Eclipse to the same directory. Note that this server is different from Apache; it is run by Eclipse inside its belly, and usually on different ports from Apache, to avoid port conflict. I think this server is run on the same user Eclipse runs, i.e., your regular user on your home comp.
I think that the error messages you get, are permission mismatch: Eclipse cannot publish in directories owned by Apache's user.
The solution is not to try to use Apache's directories but rather the default directories of Eclipse.
I have explained this in more detail here: Eclipse Web (http) servers: Debugging and publishing http files in Eclipse.
I do use both Eclipse' HTTP Preview server and Apache2:
Eclipse' HTTP Preview server for files I work on in Eclipse, and
Apache2 to run a localhost copy of my Wordpress site.
When files I work on in Eclipse, are mature, I transfer them manually to Wordpress as posts or pages.