I wrote a simple file server in NodeJS to serve a HTML page with a Save To Drive button. HTML page is served at my_address:1337 and file to be saved is served at my_address:1338. Upon clicking the Save To Drive button, it shows "Starting Download" for a long time then displays Failed Download. XHR Error.
I thought this was due to the fact that the file was being served from a different port so I decided to do the same with an appengine app. Page served at http://sayodrive.appspot.com/index.html and file served at http://sayodrive.appspot.com/drivefile.jsp, I got the same problem.
Then I decided to do a local Java web application: same problem. Then I tried changing the content disposition to attachment (to force a download) but didn't work either.
Frustrated, I started Googling and came across this page that claims the Save To Drive button doesn't actually work.
So I went back to the official Google Drive SDK page and discovered that their example button doesn't work too. Is this a bad dream?
SOURCE: index.html
<html>
<head>
<title>Test: Save To Drive</title>
<!-- -->
<link rel="canonical" href="http://sayodrive.appspot.com">
<script src="https://apis.google.com/js/plusone.js"></script>
</head>
<body>
<p>This must be the worst HTML you have ever seen :)</p>
<div class="g-savetodrive"
data-src="//http://sayodrive.appspot.com/drivefile.jsp"
data-filename="Test Drive"
data-sitename="Sayo Saves">
</div>
</body>
</html>
SOURCE: drivefile.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>DriveFile</title>
</head>
<body>
<%
java.io.Writer w = response.getWriter();
response.setContentType("text/plain");
w.write("If you're reading this in Drive, congrats!");
w.flush();
w.close();
%>
</body>
</html>
The original sample was not working because the Cache-Control header was not being exposed by the server. This is now fixed.
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range
More in the documentation.
Related
Is it possible to host web pages with .aspx extension but without dynamic code, including only HTML?
For example, index.aspx as
<!doctype html>
<head>
<meta http-equiv="content-type" content="text/html">
</head>
<body>
This is a fake ASPX page
</body>
</html>
Yes you can
Example
When you upload your file add the following metatag
Content-Type: text/html
In this case, the object is public
In my web app i allow users to download html files they uploaded.
I want to make this download to be maximum secure.
If users just open a html in new tab, it is insecure, there can be some script to catch cookies or so.
I added the header "Content-Security-Policy: sandbox" for such downloads. And it solves the problem.
But i got the problem with some subgroup of html files, which are "bookmarks". Files contain simple html like
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Opening http://example.com</title>
<meta http-equiv="REFRESH" content="0;url=http://example.com">
</HEAD>
<BODY style="font-family:Tahoma;Arial;font-size:12px;padding:20px;color:#aaa">
Opening <b>http://example.com</b>...
</BODY>
</HTML>
After it is opened in new tab, i need a user to be redirected to the host in the file.
It works without the header "Content-Security-Policy: sandbox" , but doen't work with it.
I tried different sandbox modes
Content-Security-Policy: sandbox allow-scripts
Content-Security-Policy: sandbox allow-top-navigation
But nothing allows to execute that redirect.
is there a way to do it?
I had a client that gave a URL in a press kit before the website was done. He gave a page when I was making the website a one page site. So I took the URL he made and coded it as a redirect to scroll to that part of the site.
Now that I have it online, it isn't working properly.
fuzzripper.com/bio gives me an internal server error
fuzzripper.com/bio.html works just fine
I would like it to work even if the user doesn't type .html
Here is my redirect code
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=http://www.fuzzripper.com/#about">
<script type="text/javascript">
window.location.href = "http://www.fuzzripper.com/#about"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow this <a href='http://www.fuzzripper.com/#about'>link</a>.
</body>
</html>
A quick fix for static sites is to
Create a /bio folder
Move bio.html in bio folder
Rename bio.html to index.html
This should make the bio#about link work just fine.
I've just started following a tutorial, and not even the evergreen "Hello world" works.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>
This is in wwwroot and any other code in the project is VS generated boilerplate. I would expect to see a Hello header on my page when I run the project, but there is nothing visible, even if I view page source the page is completely snow white.
If you want ASP to serve up an index.html file you'll need to enable it by adding UseDefaultFiles() and UseStaticFiles() in your Startup.cs Configure() method.
https://docs.asp.net/en/latest/fundamentals/static-files.html#serving-a-default-document
So my domain is pointed at a redirect file which in turn loads the first page in a website.
It has worked in the past. The host recently switched servers though and said it would be seamless. Now when you navigate to www.AiySlumlords.com it hits the redirect then fails to load the second page. HOWEVER, if you hit refresh after it fails then it loads?
I have no clue why this isn't working. Here is the redirect file
<html>
<head>
<title>A web page that points a browser to a different page after 2 seconds</title>
<meta http-equiv="refresh" content="0; URL=./Home/f1.html">
<meta name="keywords" content="automatic redirection">
</head>
<body>
<p>If your browser doesn't automatically go there within a few seconds, you may want to go to the destination manually.</p>
</body>
</html>
Since your server is powered by IIS and ASP.NET, it's better to use ASP.NET to redirect your client, e.g. create an index.aspx page with the following content:
<%
Response.Redirect("~/Home/f1.html", false);
Response.StatusCode = (int)System.Net.HttpStatusCode.MovedPermanently;
Response.End();
%>