How can I shorten the string and return the original content later?

I have a very long string that I need to pass into a url, for example 10,000 characters. Does anyone know a good way to cut it down to 2000 characters and then return the original somehow on the server?

It's an Objective-C conversation with Ruby, but it doesn't matter.

+2


source to share


6 answers


Can you post the data? If you are using GET, the maximum url length is around 4000 characters. If you are using POST, you have no limit (other than memory timeouts, etc.)



This article talks about executing a message from objective-c

+5


source


Are you sure you need to pass it as a URL? Maybe POST-Data or Session would be more appropriate? otherwise, you could store the row in the database and return the key of the inserted record as a URL parameter. If it's a security issue (since people can just change the number if it's an integer key), you can create a UUID key as a key.



+1


source


Store it in the database and then just pass the string id in the url.

+1


source


You can try running it through Base64 . If the string is guaranteed to have only a subset of possible characters - for example, [a-zA-Z0-9] - it can be abbreviated further by converting them to unique ordinals and using a higher base encoding.

But it would be easier to just use POST.

0


source


Well, compress it and Base64 encode the result. If the string is in a very specific format, a custom encoding may even give better compression. Can you give an example?

0


source


I would store this information in a database (or any other persistence source) and then pass a link to it in the url.

Both source and target will require database access, but this is not a problem in most cases.

0


source







All Articles