-1

i tried to download a File with ASIHTPP. I tried on my jailbroken Ipad and see that the Code download a File but no in the Documet Folder. So what is wrong? In Xcode is not a Error only a Warning that the documtensdirectory a unused variable is.

 - (IBAction)grabURLInBackground:(id)sender
{

   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   NSString *documentsDirectory = [paths objectAtIndex:0];
   NSURL *url = [NSURL URLWithString:@" http://db.tt/5WP2pia"];
   ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setDownloadDestinationPath:@"/var/root/osk.rar"] 
   [request setDelegate:self];
   [request startAsynchronous];

}
  • Gotta love it when people change the question when they have their answers instead of asking a new one. Deleting my answer since it's obviously obsolete now. – Joachim Isaksson Jan 29 '12 at 18:30

1 Answers1

0

You are setting the documents folder as destination path. You need to specify a file name inside the documents folder as download path like this to make it work:

[request setDownloadDestinationPath:[documentsDirectory stringByAppendingPathComponent:@"myfile.extension"]];

This saves the downloaded data in the file myfile.extension inside the documents folder.

You should also set a temporary download path, otherwise the downloaded bytes get stored in the memory until the download is finished rather than in a file.

JonasG
  • 9,274
  • 12
  • 59
  • 88
  • Ok can anyone give me an example code in the Right form to download the File in the Document Folder and copy it in var/root. Thank for all but i´m new in Xcode can also anyone pls give me a full Code. The File name is ok.deb – user1165127 Jan 29 '12 at 11:21
  • You should download it directly to /var/root so do `[request setDownloadDestinationPath:@"/var/root/ok.deb"]` you need to have root provileges tho to write to the root directory more info here: http://stackoverflow.com/questions/7841344/error-permission-denied-when-accessing-ios-filesystem-jailbreak/8796556#8796556 And please accept (and upvote) my answer if i helped you! this is important! – JonasG Jan 29 '12 at 11:40
  • yes, but ASIHTPRequest will call `requestFailed:` with an error that the file could not be saved if you don't have root privileges. What do you need the deb for, don't do stuff on devices without the user knowing about it! You need to be careful with root privileges, you will be able to access the whole filesystem and you can easlily f*ck something up, be careful with the system files! Also there are disadvantages of root apps like no localized keyboards and other problems. – JonasG Jan 29 '12 at 12:46
  • Yes my App need Root Privileges in the instructions is an example but i don´t understand it. Can anyone German to explain it me. It will be a simple App that download a Cydia app in Deb format and copy it to AutoInstall Folder to install it. – user1165127 Jan 29 '12 at 14:08
  • Ok i do every thing to accept Root privileges but i don´t work every Time when i start the app one the Springboard it crash. The orignal app have the bash code and the reaname File is in the Bashcode. The Reanme File i give 6755 per SHH and the other File 0755. – user1165127 Jan 29 '12 at 17:55
  • Die Anleitung ist leicht zu verstehen, im notfall kann dir ein übersetzer helfen! Warum hast du jetzt die andere Antwort akzeptiert? In welcher weise hat dir die andere antwort auch nur Ansatzweise so viel geholfen wie meine? Also akzeptier meine antwort bitte wieder sonst seh ich auch gar keinen grund dir zu helfen – JonasG Jan 29 '12 at 17:58
  • Ok ich habe es geschafft mit Root Rechten zu starten. Leider musste ich per SHH die Root Rechte geben wie kann ich es machen das man schon beim installieren Root Rechte hat? Ok I've managed to start it with root privileges. Unfortunately I had to give the root access via SSH as I can do that when i have already root privileges to install? – user1165127 Jan 30 '12 at 14:05
  • du kannst nicht per ssh root rechte geben, du musst auch vorm compilieren in der main.m datei erst mal die root rechte bekommen, die dateiberechtigungen sind erst ein schritt dannach! die anleitung ist wohl echt nicht schwer zu verstehen! – JonasG Jan 30 '12 at 16:48
  • Ok ich habe alles wie in deiner Anleitung gemacht also in der the main.m setuid(0); und setgid(0); engetragen. Nur halt die Linux Befehle haben noch funktioniert also habe ich die Werte per SHH geändert. Und schonmal danke für deine Hilfe. Du hast mir wirklich weiter geholfen grade versuche ich mit an einer UIProgressbar leid geht das auch noch nicht so wirklich. Habe auch mal dir eine Email geschickt, die ich aus deinem Blog kenne.^^ – user1165127 Jan 30 '12 at 19:24
  • Google nach ASIHTTPRequest dann wird das erste ergebnis von der offiziellen seite sein, da steht alles, ansonsten sufu von SO benutzen! Ich hab auch selbst was zu tun kann dir nicht die ganze zeit helfen – JonasG Jan 30 '12 at 19:37
  • @JonasG I am also developing the same theme project and about root access privilege I do have some doubts like how to run the shared http://stackoverflow.com/questions/7841344/error-permission-denied-when-accessing-ios-filesystem-jailbreak/8796556#8796556 code through xcode only or the user have to manually create files for this? – Deepika Lalra Jun 25 '13 at 12:15