# Upload Data | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192>\
**Category:** 🎓 Courses & Articles\
**Created:** [June 15, 2020, 5:03pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192 "2020-06-15T17:03:20Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [June 15, 2020, 5:03pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/1 "2020-06-15T17:03:20Z")

</div>

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/10376245-networking-with-urlsession/lessons/17](https://www.raywenderlich.com/10376245-networking-with-urlsession/lessons/17)

---

<div class="post-metadata">

**Author:** ![jayt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jayt/32/102075_2.png) [@jayt](https://forums.kodeco.com/u/jayt)\
**Post date:** [June 20, 2020, 10:14pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/2 "2020-06-20T22:14:29Z")

</div>

When I follow the instructions in the video to create the UploadServer Vapor project, I end up with a project whose routes.swift file looks like this:

```
import Vapor

func routes(_ app: Application) throws {
    app.get { req in
        return "It works!"
    }

    app.get("hello") { req -> String in
        return "Hello, world!"
    }
}

```

I tried to adapt the code shown in the video by adding the `VideoCourse` struct as shown and the following function:

```
app.post("upload") { req -> Future<HTTPStatus> in
    return try! req.content.decode(VideoCourse.self).map(to: HTTPStatus.self) { course in
        print(course.name)
        print(course.language)
        print(course.version)
        return .ok
    }
}

```

However, this doesn’t compile; I get the error “Use of undeclared type ‘Future’”. Besides that, my project contains only one scheme named UploadServer. I don’t see the Run scheme shown in the video.

Any ideas about what I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![jefferymasontulsatec](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jefferymasontulsatec/32/102075_2.png) [@jefferymasontulsatec](https://forums.kodeco.com/u/jefferymasontulsatec)\
**Post date:** [June 26, 2020, 5:18pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/3 "2020-06-26T17:18:43Z")

</div>

When I create my Vapor project, I have more options to choose that what’s on the tutorial.

![Screen Shot 2020-06-26 at 12.07.38 PM](https://files.chunter.kodeco.com/original/3X/a/f/af74396549cee361a03a7d6d6726eba8a930fc70.png)

No matter which option I choose, I’m unable to continue with the lesson. Any thoughts on what I need to do differently?

Any advice is appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [June 29, 2020, 10:08pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/4 "2020-06-29T22:08:17Z")

</div>

First off, what version of vapor are you running? When I recorded this, Vapor 4 was just released so it may act different from Vapor 3.

---

<div class="post-metadata">

**Author:** ![jefferymasontulsatec](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jefferymasontulsatec/32/102075_2.png) [@jefferymasontulsatec](https://forums.kodeco.com/u/jefferymasontulsatec)\
**Post date:** [June 30, 2020, 6:44pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/5 "2020-06-30T18:44:21Z")

</div>

That’s the difference. I’m on 4.

---

<div class="post-metadata">

**Author:** ![cupofjoe](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/cupofjoe/32/110937_2.png) [@cupofjoe](https://forums.kodeco.com/u/cupofjoe)\
**Post date:** [June 30, 2020, 9:48pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/6 "2020-06-30T21:48:50Z")

</div>

If you’re on version 4 use this code instead… works for me…  
You will still need the enum defined at the top called VideoCourse.

> ```
> app.on(.POST, "upload") { req -> HTTPResponseStatus in
> let course = try req.content.decode(VideoCourse.self)
> print(course.name)
> print(course.language)
> print(course.version)
> return .ok
> }
> 
> ```

Passing this in JSON:  
{  
“language”: “en”,  
“name”: “Ed”,  
“version”: 4  
}

Shows the following in the console:  
**[INFO] POST /upload**  
**Ed**  
**en**  
**4.0**

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [July 7, 2020, 12:14am UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/7 "2020-07-07T00:14:18Z")

</div>

@cupofjoe Thank you for sharing you solution - much appreciated!

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [July 7, 2020, 12:14am UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/8 "2020-07-07T00:14:53Z")

</div>

@jayt @jefferymasontulsatec Do you still have issues with this?

---

<div class="post-metadata">

**Author:** ![jayt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jayt/32/102075_2.png) [@jayt](https://forums.kodeco.com/u/jayt)\
**Post date:** [July 7, 2020, 3:25pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/9 "2020-07-07T15:25:48Z")

</div>

@shogunkaramazov Just tried the recommended solution of @cupofjoe, works for me. Thanks!

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 7, 2020, 6:59pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/10 "2020-07-07T18:59:53Z")

</div>

For Brian Moakley re: URLSession, session 16, Install Vapor. One small procedural detail for XCode 11 systems that are relatively new: The XCode =\> Preferences =\> Locations tab needs to have Command Line Tools selected. (in my case, Xcode 11.5 is the only option). if not, the Terminal vapor install process fails with error - unable to find utility “xctest”, not a developer tool or in PATH. Select the Command Line Tools option, then reinstall, the error does not appear, and vapor is installed.

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 7, 2020, 7:48pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/11 "2020-07-07T19:48:47Z")

</div>

Also for Brian Moakley re: URLSession, session 17 Upload Data. At the start you enter “vapor new UploadServer”. It asks “Would you like to use Fluent?” which does not appear in your instructional video. Should the answer be Yes or No ?

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 7, 2020, 9:47pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/12 "2020-07-07T21:47:08Z")

</div>

Continuing on my Macbook Pro running MacOS Catalina 10.15.5 and continuing on session 17. I replied No to using Fluent. Then progressed to launching XCode (11.5) and opening routes.swift. The Package.swift file says, btw, says this is swift-tools-version: 5.2, vapor is 4.0.0.  
The code in the routes.swift routes function differs slightly from the video when XCode opens up for this first time. it shows “routes(\_ app: Application)” instead of the video’s "routes(\_ router: Router). No matter. When you try to compile it, it states there is one issue with Vapor: Target Integrity. Crypto requires platform version 13.0 for the IOS platform, but this target supports 8.0. As a new newbie to the Apple universe, I am not readily finding where I adjust the targeting. The same error occurs for XCTVapor.

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [July 8, 2020, 12:20pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/13 "2020-07-08T12:20:59Z")

</div>

The videos were recorded using the Vapor 3 framework so the code is gong to be different. Once we released the videos, vapor 4 dropped. I’ll see what I can do about updating this to use Vapor 4.

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 8, 2020, 3:13pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/14 "2020-07-08T15:13:41Z")

</div>

The solution to the Crypto issue here came by catching, by chance, a glance at the very upper edge of the video… it was compiling for the Mac, not for the iPhone we had been simulating. I changed the target from an iPhone to my Macbook, and it compiled.

Now, since I am on Vapor 4.0, I need to modify the code in the video with the corrected code in this forum and extending it some. The compiler rejects the video “Router” reference but accepts the original “Application” references when I change the app.post(“upload”) to app.on(.POST, “upload”), and change the router.get lines to app.get.

And by the way, if you ever remake this video, a higher resolution would be nice. The playground portion of the video is pretty fuzzy. (Been programming since 1966 and I sure appreciate high-res images over fuzzy ones. And you know what? The Mac is somewhat of an improvement over the teletype devices - with no screens at all - we used as computer consoles back then.)

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 8, 2020, 3:48pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/15 "2020-07-08T15:48:01Z")

</div>

Thanks, Brian! I am moving on to the next session. Everything works okay, except for the final step: I could not get this playground upload to actually talk to the server. Close, but no cigar. Could be my system is too “vanilla” at this point, is missing something minor that your system has already resolved at some point in the past.

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 8, 2020, 7:19pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/16 "2020-07-08T19:19:30Z")

</div>

Brian, have advanced to your session 23… Connect to a websocket. I do exactly as your video indicates, but the result is radically different. Vapor created the project and launched XCode and the server project. I opened configure.swift file, and see it contains just one single line (try routes(app)), not the many lines of code in your example.

Please advise.

---

<div class="post-metadata">

**Author:** ![awaleh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/awaleh/32/102075_2.png) [@awaleh](https://forums.kodeco.com/u/awaleh)\
**Post date:** [July 13, 2020, 2:02pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/17 "2020-07-13T14:02:46Z")

</div>

Thank you swift\_5\_courses for sharing, it helped me​:grinning:👍🏼

---

<div class="post-metadata">

**Author:** ![swift\_5\_courses](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/swift_5_courses/32/81494_2.png) [@swift\_5\_courses](https://forums.kodeco.com/u/swift_5_courses)\
**Post date:** [July 14, 2020, 3:40pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/19 "2020-07-14T15:40:33Z")

</div>

Brian, here is something to fix in the Vapor installation sequence. The video takes us to Homebrew and checks what version of Vapor it is hosting. The video shows it found Vapor version 3.2.0. However, that is not Vapor for Swift. That VAPOR is the Visualization and Analysis Platform for Ocean, Atmosphere, and Solar Researchers.  
(The website URL shown on your video is [GitHub - NCAR/VAPOR: VAPOR is the Visualization and Analysis Platform for Ocean, Atmosphere, and Solar Researchers](https://github.com/NCAR/VAPOR). Check it out!)

Meanwhile, the formulae area in Homebrew, below the cask area mentioned above, currently indicates they host “Vapor” version 18.0.0. They indicate this is the command-line tool for Vapor (Server-side Swift web framework). After following the video instructions, and then typing in “brew info vapor”, it informs me it did install 18.0.0 (bottled), HEAD.

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [July 17, 2020, 11:38pm UTC](https://forums.kodeco.com/t/upload-data-raywenderlich-com/112192/20 "2020-07-17T23:38:55Z")

</div>

Hey there, thanks for the heads up. I’ve gone ahead and updated the install video. I’m in the process of updating this video for Vapor 4 (as well as the websocket video). I appreciate the feedback. Cheers!
