简体   繁体   中英

NSURL URLWithString to a relative url

I want to upload a image(UIImage) from ios app to django website.(where has forms and submit button, just like normal web page.)

So I decide to use ASIFormDataRequest for that. (I'm a noob, am I doing right?)

First,

NSURL *url = [NSURL URLWithString:@"http://someec2site/profile/album/2/upload/"];

Error: The current URL, profile/album/2/upload/ , didn't match any of these.

So, I did,

NSURL *url = [NSURL URLWithString:@"http://someec2site/profile/albums/(?P<album_id>\d+)/upload/"];

ERROR: Unknown escape sequence '\\d'

I have a question.

1) Am I doing right?

2) How can I grab a relative url for string? (redirecting urls based on url.py)

First of all Your choice of using ASI is very good for HTTP requests.

If I am not mistaken you are trying to construct the upload urls for different album ids.

Why don't you try this:

NSString * urlString = [NSString stringWithFormat:@"http://someec2site/profile/album/%d/upload/",albumId];
NSURL * url = [NSURL urlWithString:urlString];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM