Guest User

Untitled

a guest
Oct 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. export class MyComp {
  2. function save() {
  3. let data : ArrayBuffer = this.readFile(this.file);
  4. this.imageService.upload(data);
  5. }
  6. }
  7.  
  8. @Injectable()
  9. export class ImageService {
  10. private http: Http;
  11.  
  12. constructor(@Inject()http: Http) {
  13. this.http = http;
  14. }
  15. upload(image: ArrayBuffer) {
  16. let headers = new Headers({ 'Content-Type': 'image/png' });
  17. //let arr = new Int16Array(image);
  18. //let body = String.fromCharCode.apply(null, arr);
  19. return this.http
  20. .put('/upload', body, { headers: headers })
  21. .map(response => response.json());
  22. }
  23.  
  24. export class Request {
  25. // TODO: support URLSearchParams | FormData | Blob | ArrayBuffer
  26. }
  27. export class Response {
  28. // TODO: Support ArrayBuffer, JSON, FormData, Blob
  29. }
Add Comment
Please, Sign In to add comment