How to read a table from a Box shared link (url) in R? - r

I need to read in a text file shared via Box.com - I'll use mtcars.txt as an example.
WES.ped.exp <-
read.table("https://ucsf.box.com/s/tht30egddqjqlq3koucqy7rhtzkh3ydi")
Problem is the shared link takes me to a viewer interface, from where one is supposed to click Download, and not directly to the plain .txt file.
When reading the table, it just reads HTML lines, like so:
I've tried curl, scan and just read.table , any ideas?

Go to the share setting of the file in question. Click on "Share", go to the settings, and make sure the file's shared link is set to "Anyone with the link can view and download this file", in order to generate a direct link.
Go to the little settings icon, copy the "Direct Link", and paste it into the following:
read.table("https://ucsf.box.com/shared/static/whateverthelinksays.txt")

Related

Show .txt file on a Hyperlink using WordPress

I want to show a text file online as a description when users click on a link, and I want it to be a text file, not the html page. I want it just like this link https://wordpress.org/plugins/about/readme.txt.
I have uploaded the .txt file and it opens when the user clicks hyperlink, but contents of that .txt file are not shown....
Any idea what I did wrong?
Its about File-Permissions, you have to set them to Public & Read
This solution is provided to "Online Sites" only. (Not for XAMPP)
Go to Your Admin Panel
Go to Media
Upload your Textfile to your Webserver
Browse your Textfile (via FTP-Client) and make a RightClick
Set CHMOD to 744. (read)(This are File-Permissions)
Open the File in your Browser and it should appear normally.
I've tested it 5 Minutes ago, it should work for you.
If you check the link using Developer Tools (on Chrome) or using Firebug (on Firefox), you'll know that the file is missing. You have not uploaded the file to that location.

Possilble to auto open a downloaded word document downloaded in browser

The requirement is sent a Word document from browser, and automatically open it on MS Word so that then can view and edit the Word document.
The only solution I can found require the end user to click a dialogue Window in order to open a Word document in Office when the document is download from browser.
Is this the only way, that the user has to click a dialogue Window before Office can open the downloaded Word document?
It kinds of make sense for security reason to not let browser automatically execute an local application (Word.exe) on the local machine, but I still want to confirm that.
If the answer is yes, then I would like to know how to do that?
Edit: I just found out that you have to use inline instead of Attachement, otherwise it will always ask for the option event the browsers are setup properly.
Response.AddHeader("Content-Disposition", "inline;filename=clientquotes.docx");
After made that change, browser will auto open the Word document without asking for action.
If I understand correctly, you want to change the behaviour of your browser to automatically open downloaded files. As far I'm aware its pretty painless process when it comes to Firefox and Google Chrome, however on IE it's not as simple.
Firefox
Changing download actions
This will not affect media embedded in a web page - only links to the files themselves.
Click the menu button Menu and choose Options
Select the Applications panel.
The Applications panel will display. Select the type of file for which you want to change the default action.
The Action column will give you a drop-down menu, with options on action to take, whenever you click that type of file.
Alwaysask: will prompt you to select what action you want Firefox to take when you click on that type of file. This can be useful if Firefox is automatically saving a file type or is always opening it with a certain program and you want to be asked what to do.
Save File: will always save the file to your computer using the Downloads window, whenever you click that type of file.
Open the file with an application or plugin of your choosing.
Click Ok to close the options window after making changes
Adding download actions
On the web, find a link to a file matching the type you want to add.
Click on the file link to download it.
Select how you want Firefox to handle the file:
Open with: Saves the file to a temporary folder and opens it in the default application for that file type. To select an application, click Browse....
Do not choose Firefox to always open a certain file type, as doing so can cause
a problem where Firefox repeatedly opens empty tabs or windows after you click on a link.
Save file: Saves the file to the download folder (specified in the Firefox General panel).
In the Opening file window, check mark Do this automatically for files like this from now on.
Click Ok.
Is Do this automatically for files like this from now on disabled?
This can happen if the website's server incorrectly specifies the
Internet Media type of the file. It also can happen if the server assigns
"Content-Disposition: attachment" to the file.
Reference
Google Chrome
If you want certain types of file always to open after they've finished downloading, click the arrow next to the file button in the downloads bar and select Always open files of this type.
Reference
IE
From what I can gather for IE you will have to change the registry keys. You can refer to this link for further information.
I hope this answers your question.

Test Local Background Image on Live Site with Chrome Dev Tools?

Is there any way to use Chrome dev tools to test different images? I have created a new background graphic and I would like to test it on a live site that already has a background graphic on the <body> tag. I don't want to change the live site yet, though. Just test it to see what the new image looks like. Is this possible?
Here is the answer, courtesy of Rob Donovan # superuser (via https://superuser.com/a/839500/454034)
Since you mentioned 'Chrome', you could use Chrome extensions to do this, to enable local access to your files.
Follow these steps:
1) In the local folder where your image(s) are, create this file called 'manifest.json' and enter this:
{
"name": "File Exposer",
"manifest_version": 2,
"version": "1.0",
"web_accessible_resources": ["*.jpg","*.JPG"]
}
2) Put this is your chrome address bar: chrome://extensions/
3) Make sure 'Developer mode' is checked (Top right of page)
4) Click the 'Load Unpacked Extension' button
5) Navigate to the local folder where the image(s) and the manifest.json file is, click ok
6) The extension 'File Exposer' should now be listed in the list, and have a check mark against 'Enabled'. If the folder is on a network drive or other slow drive or has lots of files in, it could take 10-20 seconds or more to appear in the list.
7) Note the 'ID' string that has been associated with your extension. This is the EXTENSION_ID
8) Now in your HTML you can access the file with the following, changing the 'EXTENSION_ID' to whatever ID your extension generated:
<img src='chrome-extension://EXTENSION_ID/example1.jpg'>
Note, that the *.jpg is recursive and it will automatically match files in the specified folder and all sub folders, you dont need to specify for each sub folder. Also note, its Case Sensitive.
In the 'img' tag you don't specify the original folder, its relative from that folder, so only sub folders need to be specified.
If you modify the manifest.json file, you will need to click the 'Reload (Ctrl+R)' link next to the extension.
Another option would be to start a simple http server.
In your terminal (or command prompt), cd into the directory where your images are saved and then type python -m SimpleHTTPServer for Python 2.
For Python 3 use the following command: python -m http.server [<portNo>]
Now you can reference the images in dev tools using http://localhost:8000/filename.jpg.
This is not an exact answer to your question, but one way you could do it is to use something like dropbox public folder. Once the image is in the folder you can just right click and copy a public url to use in the dev tools.
I think the best and simplest solution is to convert your image into Base64 (you can use any online/offline tool for that) and then just paste the output inside DevTools.
If you need it in an IMG tag, do it like that:
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
If you need it as a background image, you can do it like that:
.background {
background-image: url("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==");
}
My, what a difference six years makes! Found this drop-dead-simple method at https://umaar.com/dev-tips/174-drag-drop-image-local-overrides/
Open the Chrome inspector preferences.
Check "Enable Local Overrides."
Locate the original image in the html.
Right-click the file path, and choose "Locate in Sources Panel."
With the image selected in the left panel of the Sources panel, drag
the replacement image from your desktop and onto the preview panel
on the right.
As you hover, you'll see a dotted outline with the text "Drop image
file here." Drop image file there. ;-)
You may need to refresh the page for the new image to display. Yes,
it will persist as long as the Inspector is open and "Local
Overrides" is enabled.
NOTE: The file name will not change in the browser, but the new image will display where the original one displayed previously.
You can replace the url of the background image in the Elements panel with the url of the image you wish to try. Check this link to see how that is done.
This change will show effect immediately in your browser window. As Johan Linder mentioned, you will have to host the image somewhere in case you have the image on your computer.
nate wilton's answer correctly points out how to do this using a Chrome extension.

Opening an Excel .xlsx file in IE and following its embedded hyperlinks back to file server

I have an intranet site that lets users open files in the browser (by prompting for download). One of these files is an .xlsx workbook that contains hyperlinks which point to different locations of files (.pdfs, .docs) on the file server in which the .xlsx workbook is located.
It seems the file server path to the workbook is replaced by a "Temporary Internet Files/Content.IE5/" path, leading to the warning "cannot open the specified file" in Excel.
I tried downloading the Excel document first and then following the links, but they're still opening in the temp internet location
EDIT:
For instance, when hovering over the hyperlinks in excel they read: "file:///C:\Documents And Settings\%username%\Local Settings\Temporary Internet files\Content.IE5\40WSS3CB\" + filename
when they should read: "file:///\servername\Departments\Read\" + filename
How can I still open the excel file in the browser and retain the hyperlinks inside and have them not be replaced by the temporary internet files path?
can someone point me in the right direction ? Thanks!
I did some testing, and it almost comes from the way you store links. If you browse through the dialog of Insert hyperlink, then you will end with relative urls. That is, the common base is stored as a reference to the current xlsx file path, and the remainder is stored and displayed as link.
You are totally in the issue Richard Hare mentions, so following the procedure from the microsoft support site should help. It did the trick on my test at least.
UPDATE to sum up down.with.the.bass comments :
One option to solve this, if doable, is to open xlsx file from its network share location and not through the website. If it is forbidden for whatever reason, you may be able to update the links using a macro.
Do you have an option like "Update links on save" enabled?
In an earlier version of Excel it was set in Tools, Options, General-tab, Web Options-button, Files-tab.
Try unchecking it and resaving the document.
I just did in my server the same task (the one I understood):
Uploaded the hyperlink to some asp.net webpage.
<p>
test<br />
</p>
The "book1.xlsx" file has inside a cell which refers (hyperlinks) to some share directory (i.e \\NHSTXX1\TEST\MS OFFICE EXCEL - \\SERVERNAME\FOLDER\OTHER FOLDER )
And when clicked the hyperlinked cell, it opened the share directory I was looking for.
I tried with Firefox.
hope this help
Hyperlinks shouldn't just mysteriously change. I saved an excel file with a hyperlink in it - opened it with html - saved it - open it in excel again - and the link stays the same. So I'm not sure how this could be happening to you(if I understand your situation correctly).

Flex - Download asset to local

I've got an interactive presentation, and it's all working as it should.
Now I want to add a function to download the currently visible image/video.
Because this presentation has a lot of files (all stored under assets/...) and it's a pain to navigate through the assets, I want an easy way to just click a button and get a "Save as.." window.
I've managed to get the url of the media, so now I just need a way to show a "save as.." dialog to allow the users to save/download the file and save it locally.
This whole presentation should be put online, so all the files are located somewhere in the /assets/.. folder inside the project.
Any ideas of how to do this? =)
Thanks!
EDIT #1:
For now I'm using "navigateToURL" to open a new browser window with the media. This works, but is there a way to show a "Save as.." dialog instead of opening the image?
Or any other ways to do this? =)
You are looking for the FileReference class, in particular the FileReference.save( data:*,defaultFileName:String = null ) method. That will open up a "Save..." dialog to save the corresponding data object and allow you to set a default file name. I'm unsure if this class can also handle the download as I have never had a time when I needed to prompt to save something that was to be downloaded. If it cannot handle it, you'll need to look into the URLStream class. That can handle the download and either on ProgressEvent.PROGRESS or Event.COMPLETE, you simply do a URLStream.readBytes( byteArray ); to save the downloaded bytes to a ByteArray and then that is the data object you save. I would look into the FileReference class, though. Odds are it can handle downloads as well.

Resources