Loading/Downloading a URL with a space followed by a number - ios

I have a few files I'm trying to download in the following format:
http://someserver.com/movie_title 5.1.12.mov
When I place the following code on it:
mediaURL =[[mediaURL stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
I get the following result:
http://someserver.com/movie_title%205.1.12.mov
If I copy paste that into my browser on any machine, it downloads correctly. However, It won't download as an NSURL on my project; it just fails.
Any suggestions? I'm guessing it's something silly that I'm forgetting.

If I were you I would confirm that the escaping is the problem, it could be some other part of your code that is failing (if you have access to the server manually rename the file with only characters.mov)
If you try this and it works, make sure you are using the expected headers and http method (POST or GET).
Else please put the code on git so we can download it and figure out what is wrong.

I've found that the server that the video was coming from did not support streaming capabilities. I tried putting the same link on my safari browser and the item did not stream.
Thanks everyone

Related

Downloading a file using luasocket

I'm sorry if this has a simple solution, or if this has been resolved before, but I am so far removed from any kind of network programming that I really have no idea what is even wrong nor what to search for to fix it.
I would like to be able to download a json file from "https://api.coinbase.com/v2/exchange-rates" (and other places) using a language I know well, Lua, with the extension, luasocket.
I've tried using http.request and ftp.get, but neither returns any kind of information. I don't understand why I can go to that url on my browser, and it downloads a file, but I can't get the file data through luasocket. If I cannot use luasocket, then what are the differences between a request made from your web browser and a request made from something like luasocket?
As you may see the URL you have is https not plain http. You need to use encrypted connection. Use luasec for that instead of luasocket (actually luasec depends on luasocket but let's not bother for now; in short https.request from luasec is built on http.request from luasocket).
local https = require "ssl.https" --luasec
local r,c,h,s = https.request {
url = "https://api.coinbase.com/v2/exchange-rates",
sink = ltn12.sink.file(io.stdout)
}
This will print body of requested content in console.
More about luasocket's http and luasec's https.

First attempt at file download does not work. Need to click link twice and it works

I am having a really weird situation and would appreciate any help that can be provided.
My setup is pretty simple. I have an ember app that communicates with a Rails backend. I hit a certain route and a spreadsheet report is generated and placed in the public folder of the rails app. So far so good.
The rails backend then sends a response with the path to the file to the front-end that I place in a href that people can click on to download the file. This is where the weirdness happens. The first time that the link to download is clicked, I get a 404. What's weird is that if I click the link again or copy and paste the url into the address bar, the download works. No matter how I attempt to download the file, the first attempt always fails and all subsequent attempts succeed. I even set it up so that on one click I try to download the file twice and the first attempt fails and the second one works. This is definitely not ideal though.
edit: Also ... This only happens in production. In development, the download works perfectly fine.
I have no idea what the issue is and would appreciate any help in this.
Thanks

.txt file on server wont open but same file changed to .css does?

Basically I get an error every time I try open or get this txt file via url. However when I change the extension to css it opens fine. I have tried re-uploading and it makes no difference.
Try for yourself:
http://seanbingley.comyr.com/DrKruseSite/articles.txt
http://seanbingley.comyr.com/DrKruseSite/articles.css
Thanks in advance.
Edit:
I should probably state that I am not bothered about actually opening it in a browser. I need to read data from it for my website. However I cannot read the data if it keeps giving me 404.
Also when opening the txt file locally in a browser it works fine. It's just when I try to open the same file from the server it goes wrong.
You have to add a mime-type on IIS so it can read it.
Okay so the hosting site (000webhost) does not allow txt files on free accounts.

Can't use tempurl with put method to upload

I have installed keystone and swift and had proxy-server.conf configured.
I can generate a temp url to download a object without any promblem..
But when I use the same way(I did changed the method into "PUT") to generate a temp url to upload a object I got error 401...The log said can't find authentication head...
I had tried all the way that I can think of to solve the problem but I got no luck:<
It turned out that was a silly problem caused by system date between two servers are not sync...

Error downloading file from a given URL

I am trying to download the given URL:
http://www.addic7ed.com/original/9521/7
but when i try to download the file using my Java Code:
URL url = new URL("http://www.addic7ed.com/original/9521/7");
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
FileOutputStream fos = new FileOutputStream("abc.srt");
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
The html page gets downloaded whereas the file to be downloaded should be a .srt extension file.
But when I try to download the above link using Internet Download Manager the file gets downloaded.
IDM converts the above given URL into http://www.addic7ed.com/srtcache/Supernatural/Supernatural%20-%2004x06%20-%20Yellow%20Fever.720p%20CTU.English.orig.Addic7ed.com.srt
So my question is how to achieve this in JAVA...?? Are there any API available to achieve this.
Have you looked at the HTML file? I suspect that it is actually an error page from the server, and that it contains clues about what is actually going on.
Here are some possibilities:
Maybe you need to supply authentication credentials.
Maybe the server is sending a redirect (3xx) response, and that the client side is not performing the redirect.
Maybe you need to set some extra headers to make the server realize that it should not turn the response as HTML. For example, an Accept header.
But note that the details will depend on the server that you are trying to talk to.
If I was trying to download files programmatically in Java, I would either use HttpUrlConnection or the Apache HttpClient libraries. Both will give you more control over the download process than simply using URL.openStream()
This is probably because the http response from http://www.addic7ed.com/original/9521/7 is a 302 redirect which your java code is not correctly handling. IDM correctly handles the redirect. A great tool to use if you are on a *nix based systme, or have cygwin installed on windows is curl.
curl -v http://myurl
will display all the http traffic information (request/response)
Have you tried with?
URL url = new URL("http://www.addic7ed.com/original/9521/7");

Resources