-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the client-side to upload a photo.
- Loading branch information
1 parent
9cd128a
commit 7c3cdda
Showing
4 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { HomeComponent } from './components/home/home.component'; | |
import { FetchDataComponent } from './components/fetchdata/fetchdata.component'; | ||
import { CounterComponent } from './components/counter/counter.component'; | ||
import { VehicleFormComponent } from './components/vehicle-form/vehicle-form.component'; | ||
import { PhotoService } from "./services/photo.service"; | ||
|
||
Raven.config('https://[email protected]/155312').install(); | ||
|
||
|
@@ -50,7 +51,8 @@ Raven.config('https://[email protected]/155312').instal | |
], | ||
providers: [ | ||
{ provide: ErrorHandler, useClass: AppErrorHandler }, | ||
VehicleService | ||
VehicleService, | ||
PhotoService | ||
] | ||
}) | ||
export class AppModule { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Http } from '@angular/http'; | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable() | ||
export class PhotoService { | ||
|
||
constructor(private http: Http) { } | ||
|
||
upload(vehicleId, photo) { | ||
var formData = new FormData(); | ||
formData.append('file', photo); | ||
return this.http.post(`/api/vehicles/${vehicleId}/photos`, formData) | ||
.map(res => res.json()); | ||
} | ||
} |