0

How can I upload a file that I have in my Documents/Inbox directory using Alamofire?

There are many topics on this but they all cover uploading photos, which is not what I want. I would like to upload a zip file to my that uses PHP

Below is what I use to get the file's content, but I'm not sure if this is correct:

do {
     let directoryContents = try FileManager.default.attributesOfItem(atPath: "\(NSHomeDirectory())/Documents/Inbox/file.zip")
    let Contents = directoryContents
    print("File is okay")
    } catch let error as NSError {
        print(error.localizedDescription)
    }

Edit: I tried the Alamofire examples without success: (Please note that I am uploading a file that a user has submitted through the app via "Import to" rather than a file that is inside the xcode project.)

Matt
  • 1,087
  • 1
  • 12
  • 28
  • Dupe https://stackoverflow.com/questions/41977486/how-to-upload-zip-data-with-alamofire ? – nathan Aug 03 '17 at 19:42
  • Possible duplicate of [How to upload zip data with alamofire?](https://stackoverflow.com/questions/41977486/how-to-upload-zip-data-with-alamofire) – ninjaproger Aug 03 '17 at 19:46
  • Did you review the example on the Alamofire GitHub page? https://github.com/Alamofire/Alamofire#uploading-a-file – JAL Aug 03 '17 at 19:55
  • @nathan @ninjaproger It's not a duplicate. I have already looked at this and that code throws syntax errors and use `Bundle.main.url` which does not work for me. – Matt Aug 03 '17 at 20:05
  • @JAL Yes, but unfortunately those do not help either. Those are for uploading files in the bundle – Matt Aug 03 '17 at 20:06
  • Right now it's a bit unclear if the question is how to get the file or send it using Alamofire. What have you tested and what were the results ? You need to prove more details. What do you mean by "Import to" ? – nathan Aug 04 '17 at 03:38

0 Answers0