Retrofit Jackson JsonParseException when word "Redirect" is in URL Path - retrofit2

Using Retrofit, I am making simple GET call to a server to a image file. Issue is that retrofit fails to parse the url string when it has a word name "Redirect", the destination url does have the word Redirect in it.
#GET(value = "Images/{filePath}/Redirect")
Call<InputStream> fetchIvaImage(
#Path(value = "filePath",encoded = true) String filePath
);
I would really appreciate, if anyone help me with this issue.
Thanks

Related

How to extract youtube url from string in Typescript

I have a text like
string 1 :
I am a text and this is a youtube video https://www.youtube.com/watch?v=j82FBbgpUy4 !!!
I would like to extract the youtube video url from the string and return it.
Result :
string 2 :
https://www.youtube.com/watch?v=j82FBbgpUy4
Is there another way more efficient than spliting the string by spaces and searching in the array if it contains "https://www.youtube.com/watch?v=" (it's not the best way to do it)? I cannot find any other solution
So. I found this regular expression http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?‌​[\w\?‌​=]*)?, here, which seems to work.
Once you have that, all you have to do is this:
var re = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?‌​[\w\?‌​=]*)?/;
var str = "I am a text and this is a youtube video https://www.youtube.com/watch?v=j82FBbgpUy4 !!!"
var url = re.exec(str)['0']
Then url should have the video url.

Start and stop parsing of a string

I grab a url and I want to parse and store two sections of the url
User/Confirmation?=QVNERkFTREY=&code=MTAvMjMvMjAxMyAxMjowMDowMCBBTQ==
So I want to start at (Confirmation?=) and stop at (&) and store the results
string = QVNERkFTREY
then for the second one I want to start at (&code=) and go to the end of the string and store that result
string = MTAvMjMvMjAxMyAxMjowMDowMCBBTQ==
I was have tried a few different things
Uri myUri = new Uri(Request.Url.AbsoluteUri);
string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("Confirmation?=");
string param2 = myUri.Query.Split();
Pretty sure I should be going a different route here but any help would be appreciate. I am going to continue to google search for now. I appreciate the help.
EDIT: I feel as though LINQ should be able to help me here..hmm
I would use HttpUtility.ParseQueryString rather than try to parse the URL myself.
String val = "User/Confirmation?=QVNERkFTREY=&code=MTAvMjMvMjAxMyAxMjowMDowMCBBTQ==";
System.Collections.Specialized.NameValueCollection parameters = System.Web.HttpUtility.ParseQueryString(val);
Console.Out.WriteLine(parameters[0]); // QVNERkFTREY=
Console.Out.WriteLine(parameters.Get("code"); // MTAvMjMvMjAxMyAxMjowMDowMCBBTQ==
You will need to add System.Web.dll, which you can read about here: Cannot add System.Web.dll reference

FreeImage .NET Blank FileName when not constant

Can somebody explain me please why FreeImage library is not recognizing my variable as a valid filename for the method Load, I tried the following code:
var fileName = "C:\\images\\myimage.tif";
var dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_TIFF, fileName, 0);
And it's not working, the object dib is always empty (the image is not being loaded), but when I tried the following code:
const string fileName = "C:\\images\\myimage.tif";
var dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_TIFF, fileName, 0);
The result is successful, the problem is that I need that image path value to be a normal variable (NOT const), because I work with different images each time, and this images could be anything.
How could I solve this issue, or it's a limitation of the library?
Thanks.
The first thing I see, you are setting the first example as a var instead of string. Define your variable as a string.
I would try that, you dont need the const to make it work I don't believe.
string fileName = "C:\\images\\myimage.tif";

URL String containing %26 converts when escaped using NSString

I have a URL string which contains a %26
the part in the URL string is : http://......(bkd %26 2)=2..........
I am using the following line of code to take care of escape characters for creating a valid URL:
NSURL *url = [NSURL URLWithString:[scriptURLString stringByAddingPercentEscapeUsingEncoding:NSUTF8StringEncoding]];
When I the NSMutableURLRequest to post the data, there is an error in getting the response.
The part of the URL string above given in bold is now set in the URL string as : %202=2
instead of %20%26%202%29=2
How do I make sure it is encoding correctly?
Please advice.
Thanks,
Subbu

Path.Combine with spaces in passed parameter?

string exeFile = (new System.Uri(Assembly.GetEntryAssembly().CodeBase)).AbsolutePath;
string exeDir = Path.GetDirectoryName(exeFile);
string fileName = Path.Combine(exeDir, #"..\..\xml\SalesOrderXMLData.csv.xml");
Hello,
The above code works if the project is in, for example,
C:\Code\
but not if its in
C:\Documents and Settings\Naim\My Documents..
If i have the string, i would use escape characters where needed, but in this case, i dont know how to get around this.
Update: result fileName = "D:\Naim\My%20Documents\Visual%20Studio%202008\Projects\XML_Gen\XML_Gen\bin\Debug\..\..\xml\SalesOrderXMLData.csv.xml"
Any help appreciated.
Thanks
It's probably the URI. Use Assembly.GetEntryAssembly().Location, and pass it directly to Path.GetDirectoryName().
code below works, though I don't know why the above wasn't working. Changed AbsolutePath to LocalPath
string exeFile = (new System.Uri(Assembly.GetEntryAssembly().CodeBase)).LocalPath;
string exeDir = Path.GetDirectoryName(exeFile);
string fileName = Path.Combine(exeDir, #"..\..\xml\SalesOrderXMLData.csv.xml");

Resources