-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2eeadcb
commit eb87f68
Showing
7 changed files
with
106 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
w150 { | ||
width: 150px; | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { UpLoadFileService } from './up-load-file/up-load-file.service'; | ||
export { SettingsService } from './settings/settings.service'; | ||
export { SharedService } from './shared/shared.service'; | ||
export { SidebarService } from './shared/sidebar.service'; |
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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
// Services | ||
import { SettingsService, SharedService, SidebarService } from './service.index'; | ||
import { SettingsService, SharedService, SidebarService, UpLoadFileService } from './service.index'; | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule | ||
], | ||
declarations: [], | ||
providers: [ | ||
SettingsService, | ||
SharedService, | ||
SidebarService | ||
SidebarService, | ||
UpLoadFileService | ||
] | ||
}) | ||
export class ServiceModule { } |
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,49 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { resolve } from 'q'; | ||
|
||
@Injectable() | ||
export class UpLoadFileService { | ||
|
||
// The code is in JS plain becuase Angular don't support work with Files | ||
|
||
constructor() { } | ||
|
||
upLoad(file: File, type: string, id: string) { | ||
|
||
let promise = new Promise((res, rej) => { | ||
|
||
// I send by AJAX | ||
let fromData = new FormData(); | ||
let xhr = new XMLHttpRequest(); | ||
|
||
// File Data | ||
fromData.append('keyBody', file, file.name); | ||
// Peticion AJAX | ||
xhr.onreadystatechange = () => { | ||
|
||
// I used only this state when the peticion is UP, but I can used other states(EX: loading) | ||
if (xhr.readyState === 4) { | ||
if (xhr.status === 200) { | ||
console.log('File UpLoad'); | ||
resolve(xhr.response); | ||
} else { | ||
console.log('File UpLoad Fail !!!!'); | ||
rej(xhr.response); | ||
} | ||
} | ||
}; | ||
|
||
let urlBase = `http://address.com`; // Address Example | ||
let urlService = urlBase + `/upload/` + type + `/` + id; // Example | ||
|
||
xhr.open(`PUT`, urlService, true); | ||
xhr.send(fromData); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
} |