This commit is contained in:
parent
3cb36e2d29
commit
843c9bc075
6
src/app/models/picResponse.ts
Normal file
6
src/app/models/picResponse.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export interface IPicresponse {
|
||||||
|
contentType: null
|
||||||
|
serializerSettings: null
|
||||||
|
statusCode: null
|
||||||
|
value: string
|
||||||
|
}
|
@ -7,5 +7,5 @@
|
|||||||
<h1>Загрузить картинку:</h1>
|
<h1>Загрузить картинку:</h1>
|
||||||
<input type="file" #file placeholder="Загрузить картинку" (change)="sendPic($event)" style="display:none;">
|
<input type="file" #file placeholder="Загрузить картинку" (change)="sendPic($event)" style="display:none;">
|
||||||
<button type="button" class="btn btn-success" (click)="file.click()">Загрузить картинку</button>
|
<button type="button" class="btn btn-success" (click)="file.click()">Загрузить картинку</button>
|
||||||
<p>{{filename}} : {{progress}}</p>
|
<p>Картинка в статике: {{filename}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { ApiChatService } from '../services/api-chat.service';
|
import { ApiChatService } from '../services/api-chat.service';
|
||||||
import { MinIoService } from '../services/min-io.service.'
|
import { MinIoService } from '../services/min-io.service.'
|
||||||
|
import {IPicresponse} from "../models/picResponse";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-send-post',
|
selector: 'app-send-post',
|
||||||
@ -11,20 +12,25 @@ export class SendPostComponent implements OnInit {
|
|||||||
|
|
||||||
progress: number;
|
progress: number;
|
||||||
message: string;
|
message: string;
|
||||||
filename = '';
|
filename = '0';
|
||||||
|
|
||||||
|
picResponse: IPicresponse
|
||||||
|
|
||||||
|
|
||||||
constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) {
|
constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sendPost(text: string) {
|
sendPost(text: string) {
|
||||||
this.apiChatService.sendPostToApi(text).subscribe();
|
this.apiChatService.sendPostToApi(text, this.filename).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPic(event: any) {
|
sendPic(event: any) {
|
||||||
this.filename = event.target.files[0].name;
|
this.apiChatService.sendpic(event.target.files[0]).subscribe(
|
||||||
//console.log(event.target.files[0]);
|
response => {
|
||||||
this.apiChatService.sendpic(event.target.files[0]).subscribe();
|
this.picResponse = response
|
||||||
|
});
|
||||||
|
this.filename = this.picResponse.value.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@ -12,28 +12,29 @@ export class ApiChatService {
|
|||||||
|
|
||||||
getPosts(): Observable<SinglePost[]> {
|
getPosts(): Observable<SinglePost[]> {
|
||||||
console.log("Получаю посты и картинки");
|
console.log("Получаю посты и картинки");
|
||||||
return this.http.get<SinglePost[]>('http://api.vdk2ch.ru:5000/List/');
|
//return this.http.get<SinglePost[]>('http://api.vdk2ch.ru:5000/List/');
|
||||||
//return this.http.get<SinglePost[]>('http://localhost:7141/List/');
|
return this.http.get<SinglePost[]>('http://localhost:7141/List/');
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPostToApi(text: string) {
|
sendPostToApi(text: string, imgUrl: string) {
|
||||||
console.log("Отправляю пост...");
|
console.log("Отправляю пост...");
|
||||||
var postToSend =
|
var postToSend =
|
||||||
{
|
{
|
||||||
Timestamp: text,
|
Timestamp: text,
|
||||||
Id: 0,
|
Id: 0,
|
||||||
Text: text,
|
Text: text,
|
||||||
ImgURL: "0"
|
ImgURL: imgUrl
|
||||||
}
|
}
|
||||||
return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
|
console.log(postToSend)
|
||||||
//return this.http.post('http://localhost:7141/PostTo', postToSend)
|
//return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
|
||||||
|
return this.http.post('http://localhost:7141/PostTo', postToSend)
|
||||||
|
|
||||||
}
|
}
|
||||||
sendpic(picToSend: File) {
|
sendpic(picToSend: File):Observable<any> {
|
||||||
const PostPicture = new FormData();
|
const PostPicture = new FormData();
|
||||||
PostPicture.append('PostPicture', picToSend);
|
PostPicture.append('PostPicture', picToSend);
|
||||||
//return this.http.post('http://localhost:7141/UploadPic', PostPicture)
|
return this.http.post('http://localhost:7141/UploadPic', PostPicture)
|
||||||
return this.http.post('http://api.vdk2ch.ru:5000/UploadPic', PostPicture)
|
//return this.http.post('http://api.vdk2ch.ru:5000/UploadPic', PostPicture)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user