Using #Google #Drive as http server

Well, maybe you don’t know but you can use G Drive to show a html page!

Make the a Google Drive folder public and get the correct URL following the instructions here!

Now, these are the fundamental java lines to publish a new html item.

					try {
					myFile = new java.io.File(Environment.getExternalStorageDirectory(), MYFILE);
						    if (!myFile.exists())
						        myFile.createNewFile();
						    FileOutputStream fos = new FileOutputStream(myFile);

						    	fos.write("\n<html>\n".getBytes());
						    	fos.write("\n<body>\n".getBytes());
				                for(final Tweet item : TweetSearchActivity.mytweets ){
				                	String source_str = extract_source2(item.source);
				        			String htmlurls = "";
				                	for (int index =0; index < item.urls.size(); index++){
				                		htmlurls  += format_url(item.urls.get(index));
				                	}
				                	
				                	String strText = "<p>"+item.username+" @ "+ item.date.replace("+0000", "") + "</p>" 
				                			+ "\n" + "<p>" + item.message + "</p>"
											+ "\n" + htmlurls  
											+ "\n" + source_str + "\n\n";
				                	fos.write(strText.getBytes());
				                	 fos.flush();
								}
				                fos.write("\n</body>\n".getBytes());
				                fos.write("\n</html>\n".getBytes());
						    	
				                
								
				                fos.flush();
						fos.close();		
						
					} catch (IOException e) {
						e.toString();
				    }

Here is the result in my drive’s example 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s