Picture Upload beta-4
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
RakVhalate 2022-11-03 15:37:24 +10:00
parent 3cb36e2d29
commit 843c9bc075
4 changed files with 29 additions and 16 deletions

View File

@ -0,0 +1,6 @@
export interface IPicresponse {
contentType: null
serializerSettings: null
statusCode: null
value: string
}

View File

@ -7,5 +7,5 @@
<h1>Загрузить картинку:</h1>
<input type="file" #file placeholder="Загрузить картинку" (change)="sendPic($event)" style="display:none;">
<button type="button" class="btn btn-success" (click)="file.click()">Загрузить картинку</button>
<p>{{filename}} : {{progress}}</p>
<p>Картинка в статике: {{filename}}</p>
</div>

View File

@ -1,6 +1,7 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { ApiChatService } from '../services/api-chat.service';
import { MinIoService } from '../services/min-io.service.'
import {IPicresponse} from "../models/picResponse";
@Component({
selector: 'app-send-post',
@ -11,20 +12,25 @@ export class SendPostComponent implements OnInit {
progress: number;
message: string;
filename = '';
filename = '0';
picResponse: IPicresponse
constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) {
}
sendPost(text: string) {
this.apiChatService.sendPostToApi(text).subscribe();
this.apiChatService.sendPostToApi(text, this.filename).subscribe();
}
sendPic(event: any) {
this.filename = event.target.files[0].name;
//console.log(event.target.files[0]);
this.apiChatService.sendpic(event.target.files[0]).subscribe();
this.apiChatService.sendpic(event.target.files[0]).subscribe(
response => {
this.picResponse = response
});
this.filename = this.picResponse.value.toString()
}
ngOnInit(): void {

View File

@ -12,28 +12,29 @@ export class ApiChatService {
getPosts(): Observable<SinglePost[]> {
console.log("Получаю посты и картинки");
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://api.vdk2ch.ru:5000/List/');
return this.http.get<SinglePost[]>('http://localhost:7141/List/');
}
sendPostToApi(text: string) {
sendPostToApi(text: string, imgUrl: string) {
console.log("Отправляю пост...");
var postToSend =
{
Timestamp: text,
Id: 0,
Text: text,
ImgURL: "0"
ImgURL: imgUrl
}
return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
//return this.http.post('http://localhost:7141/PostTo', postToSend)
console.log(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();
PostPicture.append('PostPicture', picToSend);
//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://localhost:7141/UploadPic', PostPicture)
//return this.http.post('http://api.vdk2ch.ru:5000/UploadPic', PostPicture)
}
}