I've been looking into the benefits of using base64 in urls and for files and I like the idea, and I can't seem to find anywhere to start. I have played around on the console encoding my picture urls too base64 which works okay(I can access it in the html decoding it in the view),
My question would be how would I do this for urls? Instead of using 1.. 2.. 3 for my users, I would like to try and use base64 for the 'users/1' instead so it would be something like 'users/U3Rvcm1WaXBlcg' for example
Not exactly, lets take discord as an wonderful example, you can copy someone's userID and then it in a base64 encoder, and boom you have the first part of someone's token. The ID in decoded is someone's token.
Related
I want to open my iOS application using a URL but my url appears to be too long? Is there a limit on the length of the URL? I've searched the web all day on this and it looks like there is no definitive answer. My url contains a base64EncodedString of an object and is about 1,500 bytes.
It looks like this:
MyApp://favorite?Class=eyJzZXR0aW5ncyI6eyJzY2FsZSI6WzAsNCwxMiwxOSwyMF0sImZyZXEiOjIyMCwidHVuaW5nIjoiZXlKelkyRnNZU0k2SWlGY2JpRWdjSFJ2YkdWdGVTNXpZMnhjYmlGY2JsQjBiMnhsYlhrZ01USWdibTkwWlNCelkyRnNaVnh1SURFeVhHNGhYRzRnTVRkY0x6RTJYRzRnT1Z3dk9GeHVJREU1WEM4eE5seHVJRFZjTHpSY2JpQTBYQzh6WEc0Z01URmNMemhjYmlBelhDOHlYRzRnTVROY0x6aGNiaUExWEM4elhHNGdOMXd2TkZ4dUlERTFYQzg0WEc0Z01sd3ZNVnh1SW4wPSIsInNvdW5kIjoiZXlKaGRIUnlhV0oxZEdWeklqcGJleUpoZEhSaFkyc2lPakl1TXprd01EQXdNREF3TURBd01EQXlMQ0prWldOaGVTSTZNQzR6TkRrNU9UazVPVGs1T1RrNU9UazVMQ0pwYzAxMWRHVmtJanBtWVd4elpTd2ljbVZzWldGelpTSTZNQzR6TlRJMU1EQXdNREF3TURBd01EQXhMQ0p3WVhKMGFXRnNJam93TGpVeExDSmhiWEFpT2pBdU1qTXpOelV3TURBd01EQXdNREF3TVN3aWMzVnpkR0ZwYmlJNk1IMHNleUpoZEhSaFkyc2lPakF1TWpVc0ltUmxZMkY1SWpvd0xqRXpOU3dpYVhOTmRYUmxaQ0k2Wm1Gc2MyVXNJbkpsYkdWaGMyVWlPakVzSW5CaGNuUnBZV3dpT2pFc0ltRnRjQ0k2TUM0M05Td2ljM1Z6ZEdGcGJpSTZNSDBzZXlKaGRIUmhZMnNpT2pBdU9URTFNREF3TURBd01EQXdNREF4TXl3aVpHVmpZWGtpT2pBdU5URXlOVEF3TURBd01EQXdNREF3TXl3aWFYTk5kWFJsWkNJNlptRnNjMlVzSW5KbGJHVmhjMlVpT2pBdU1qWXlOU3dpY0dGeWRHbGhiQ0k2TWk0eU5EazVPVGs1T1RrNU9UazVPVGdzSW1GdGNDSTZNQzR3T0RFNU9UazVPVGs1T1RrNU9UazVPU3dpYzNWemRHRnBiaUk2TUgwc2V5SmhkSFJoWTJzaU9qQXNJbVJsWTJGNUlqb3dMakkwTlN3aWFYTk5kWFJsWkNJNlptRnNjMlVzSW5KbGJHVmhjMlVpT2pBdU16Y3lOVEF3TURBd01EQXdNREF3TVN3aWNHRnlkR2xoYkNJNk5TNDNOREl3TURBd01EQXdNREF3TURFc0ltRnRjQ0k2TUM0d05UY3NJbk4xYzNSaGFXNGlPakI5WFN3aWJtRnRaU0k2SWtOc1pXRnlJRUpsYkd3aUxDSmtaWE5qSWpvaVNuVnpkQ0JoYm05MGFHVnlJR0psYkd3Z2MyOTFibVF1SW4wPSIsInRvbmUiOiJBIiwibXV0ZWQiOmZhbHNlfSwibmFtZSI6IlB0b2xlbXkgaW4gQSIsImRlc2MiOiJDbGVhciBCZWxsIn0=
I want to text or email this URL and then have the recipient tap on the link to open my app on their device.
The trouble is the link is wrapped in the mail and messages application and only the "MyApp://favorite?" part is marked in blue as a link. The remainder of the text is not part of the link.
Is there any way to send data like this via a URL?
This doesn't sound like it has anything to do with the URL itself or Swift. The problem you're describing is with "the mail and messages application." It sounds like you're sending the message in plaintext and relying on the data detector to find it. That's asking too much of the data detector, which is a heuristic guessing process. If you want to make it as a link, you should send it as an HTML mail, and mark it with <a href>.
Some notes on the format, though:
This data is double-base64-encoded, which is very wasteful. If you only encoded one time, this would be:
MyApp://favorite?Class=eyJzZXR0aW5ncyI6eyJzY2FsZSI6WzAsNCwxMiwxOSwyMF0sImZyZXEiOjIyMCwidHVuaW5nIjp7InNjYWxhIjoiIVxuISBwdG9sZW15LnNjbFxuIVxuUHRvbGVteSAxMiBub3RlIHNjYWxlXG4gMTJcbiFcbiAxNy8xNlxuIDkvOFxuIDE5LzE2XG4gNS80XG4gNC8zXG4gMTEvOFxuIDMvMlxuIDEzLzhcbiA1LzNcbiA3LzRcbiAxNS84XG4gMi8xXG4ifSwic291bmQiOnsiYXR0cmlidXRlcyI6W3siYXR0YWNrIjoyLjM5MDAwMDAwMDAwMDAwMiwiZGVjYXkiOjAuMzQ5OTk5OTk5OTk5OTk5OSwiaXNNdXRlZCI6ZmFsc2UsInJlbGVhc2UiOjAuMzUyNTAwMDAwMDAwMDAwMSwicGFydGlhbCI6MC41MSwiYW1wIjowLjIzMzc1MDAwMDAwMDAwMDEsInN1c3RhaW4iOjB9LHsiYXR0YWNrIjowLjI1LCJkZWNheSI6MC4xMzUsImlzTXV0ZWQiOmZhbHNlLCJyZWxlYXNlIjoxLCJwYXJ0aWFsIjoxLCJhbXAiOjAuNzUsInN1c3RhaW4iOjB9LHsiYXR0YWNrIjowLjkxNTAwMDAwMDAwMDAwMTMsImRlY2F5IjowLjUxMjUwMDAwMDAwMDAwMDMsImlzTXV0ZWQiOmZhbHNlLCJyZWxlYXNlIjowLjI2MjUsInBhcnRpYWwiOjIuMjQ5OTk5OTk5OTk5OTk4LCJhbXAiOjAuMDgxOTk5OTk5OTk5OTk5OTksInN1c3RhaW4iOjB9LHsiYXR0YWNrIjowLCJkZWNheSI6MC4yNDUsImlzTXV0ZWQiOmZhbHNlLCJyZWxlYXNlIjowLjM3MjUwMDAwMDAwMDAwMDEsInBhcnRpYWwiOjUuNzQyMDAwMDAwMDAwMDAxLCJhbXAiOjAuMDU3LCJzdXN0YWluIjowfV0sIm5hbWUiOiJDbGVhciBCZWxsIiwiZGVzYyI6Ikp1c3QgYW5vdGhlciBiZWxsIHNvdW5kLiJ9LCJ0b25lIjoiQSIsIm11dGVkIjpmYWxzZX0sIm5hbWUiOiJQdG9sZW15IGluIEEiLCJkZXNjIjoiQ2xlYXIgQmVsbCJ9
which saves over 350 bytes over your current approach.
If you run this through gzip before Base64-encoding it, it'd be a third of this size (~550 bytes). And using a binary format, you could probably get this down to ~200 bytes (after base64-encoding) without even getting clever.
That said, URLs are perfectly capable of handling data of this size. I suspect your problem is just asking heuristic systems to detect the URL rather than marking exactly where it is with HTML.
I am creating a website which allows users to post links to gif images stored externally. Unfortunately gifs are terribly expensive and luckily I have found the following website which compresses them quite radically: http://gfycat.com/
Currently my app stores the url to the linked image (as of yet it is uncompressed and without the use of gfycat)
What I would like to do is to take the url that the user posts, use it to compress the gif via gfycat.com and then store the newly generated url (pointing to the compressed image) in my database.
How would I do this?
Sorry for the long explanation btw
Just took a look at gfycat.com, seems like they do have an accessible webservice at http://gfycat.com/fetch/:url
If this is the case, and you already have the URL you can very easily grab the 'minified' version of the gif by grabbing the URL and saving the file.
So, I would probably do something like this:
Install carrierwave or another image upload gem of your choice
In the case you used the above gem...
assuming Cat is your model, and you have an uploader attached to it named gif_photo, and also assuming the original 'gif' url is stored as original_gif_url
You can do something like the following (assuming #cat is some instance of the cat model):
#cat.update_attribute(:remote_gif_photo_url, "http://gfycat.com/fetch/#{#cat.original_gif_url}")
as simple as that :)... to get back at the gif, you can simply call #cat.gif_photo_url
(again, assumptions for code above are using carrierwave syntax, but can easily be done with any of its alternatives.)
I've encountered an interesting solution to importing/exporting data through email. This particular solution doesn't involve attaching any files and also "encrypts" the information, such that it's not easy to decipher.
I'd like to know if anyone has an idea about how this is done.
Basically, this app allows you to export a custom-selected set of data by emailing you a link. The link is a URL scheme that opens the app and asks if you want to import the data. The data looks like it's encrypted, but I'm not sure. Below is an example of a link that the app generates. Does anyone know how this is accomplished?
Thank you!:
appofinterest://#;;bm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G90YWxMaWZldGltZURvc2U=;ODUgbWc=;;c3RhcnREYXRl;MjAxMi0wMS0xNSAwMDowMA==;;c3RvcERhdGU=;MjAxMi0wNS0xMCAwMDowMA==
You could just convert your data to base64 (which is the case here*). Remember that URI are not (practically) unlimited in length and might, like the link you posted, be a little meaningless for your users.
(*) in the case you posted, the data is separated by semi-columns, for example "TmV3IFByb2ZpbGU=" is base64 for New Profile, and the big chunk in the middle is a base64 encoded PNG. Absolutely not secure - since it's not encrypted in any way, but could be fairly easily
Very simple question.. strangely can't find any intuitive answers anywhere.
I got a HTML form with which allows users to upload an image.
When this form is submitted and goes to a Rails controller, how do I get the image? Suppose I want it in base64.
When I do:
image = params["image"]. I just get a filename... but where is this file? is it in my server? How do I then convert this to base64? I guess the conversion is easy once I know where this file actually is in my server...
params['image'] should be an instance of Rack::Multipart::UploadedFile, so you should be able to access the path on disk by doing params['image'].path.
P.S.: To save a character, most prefer to use symbols since most Rails hashes are HashWithIndifferentAccess and can be accessed using a symbol or a key. So params[:image].path :-)
I'm trying to delete blobs in an mvc 3 application that uses azure storage.
I'm trying to pass the Uri of the blob which will be deleted to the controller, however an error is thrown:
A potentially dangerous Request.Path value was detected from the client (:)
I think this is from the https: part of the Uri and I need to parse it out, however I'm not sure how to do that. I'm wondering how to fix this error.
Is there a more graceful way to delete a blob from storage?
You must properly URL encode your urls. Here's an example of a badly encoded url:
http://foo.com/controller/action?param=http://bar.com
Here's how it should look like:
http://foo.com/controller/action?param=http%3A%2F%2Fbar.com
Or maybe you are having an url of the form:
http://foo.com/controller/action/https://bar.com
which is even worse. If you want to use special characters in the Path portion of an URL you might find the following blog post useful.
If you want unsecure content to get through then you can add [ValidateInput(false)] to your action - however, this is opening up something that is there for your security - so only do this if you are sure you're code is secure - see first answer in A potentially dangerous Request.Form value was detected from the client
I was able to fix it and I want to summarize the solution, since it requires bit from the other two answers and bits mostly from the Scott Hanselman Blog post.
You need to do a few things to make this work:
Put the [ValidateInput(false)] on your action method.
Make sure your Url is properly encoded (an example is given in the above post) which is done when you use the blobVariableName.Uri.AbsoluteUri as the string to pass from your view to your controller, so you shouldn't have to do anything there.
Make your query string looks like
http://site/controller/action?blobid=http%3A%2F%2F... and NOT http://site/controller/action/http%3A%2F%2F... the latter won't work!
On a side note, since I started, our functional requirements changed and now were storing information about each blob in the database, which allows me to pass parameters other than the blob's uri, which seems like a much safer way to play it.
A great deal of the community appears to be in agreement that it is a bad idea to pass uri's and to open up your application as to allow you to do so.