import { HttpService } from './httpService';
import mediaStore from '../stores/media.store';
export class MediaService {
  constructor() { }
  static getInstance() {
    if (!MediaService.instance) {
      MediaService.instance = new MediaService();
    }
    return MediaService.instance;
  }
  async uploadImage(files) {
    let formData = new FormData();
    for (let i = 0; i < files.length; i++) {
      formData.append("uploads[]", files[i], files[i].name);
    }
    mediaStore.state.mediaUploading = true;
    let result;
    try {
      result = await HttpService.http.post(`api/v1/MediaItems/Upload`, formData);
      if (result) {
        mediaStore.state.mediaUploading = false;
      }
    }
    catch (e) {
      mediaStore.state.mediaUploading = false;
    }
    return result;
  }
}
