Burchakli2 bilan indentifikatorlar, himoyalangan serverdan qanday qilib rasmni olish kerak

Tasvirlarning oddiy galeriyasiga nativescript va angular2 dan foydalansangiz, lekin tasvirlar himoyalangan server ostidadir .. veb-ilovasida bu tizimga cookie faylida hal qilinadi ... Bu erda men token tasdiqlashni amalga oshirishim kerak.

Rasmni men orqali yuklab olayapman:

  get(url: string) {
      let headers = new Headers();
      headers.append("Authorization", "Token " + Config.token);
      return this.http.get(this.base_url+url, { headers: headers, })
  }

mening qismlarimda:

                this.mediaService.get(obj.url_tn)
                .subscribe(data=> 

                {
                     let file:Blob = new Blob([data.arrayBuffer()]);
                     console.dump(data);
                     let urlFile =  URL.createObjectURL(file );
                     this.photos.push(urlFile) ;

                })

Lekin bu menga xato beradi:

Xato: Xato sababi: 0: 0 sababli: Blob aniqlanmagan

img ga sarlavhani qo'shish nima uchun juda qiyinligini bilmayman, qanday qilib uni osongina arxivlash mumkin?

Rahmat

0
Hozirda menda yechim yo'q, lekin sizning muammoingiz Blob NativeScript tomonidan qo'llab-quvvatlanmaydi (hech bo'lmaganda Androidda, iOS qurilmasi yo'q).
qo'shib qo'ydi muallif mabs, manba
Hozirda menda yechim yo'q, lekin sizning muammoingiz Blob NativeScript tomonidan qo'llab-quvvatlanmaydi (hech bo'lmaganda Androidda, iOS qurilmasi yo'q).
qo'shib qo'ydi muallif mabs, manba
Hozirda menda yechim yo'q, lekin sizning muammoingiz Blob NativeScript tomonidan qo'llab-quvvatlanmaydi (hech bo'lmaganda Androidda, iOS qurilmasi yo'q).
qo'shib qo'ydi muallif mabs, manba
Kechirasiz, bu chuqurroqdir. NativeScript ning qabul qilish va XMLHttpRequest o'zaro ma'lumotlar uchun qo'llab-quvvatlamaydi: github.com/NativeScript/NativeScript/issues/570 Backend nazorat qilyapsizmi, shu sababli base64 kodlashni bajarishingiz mumkin?
qo'shib qo'ydi muallif mabs, manba
Kechirasiz, bu chuqurroqdir. NativeScript ning qabul qilish va XMLHttpRequest o'zaro ma'lumotlar uchun qo'llab-quvvatlamaydi: github.com/NativeScript/NativeScript/issues/570 Backend nazorat qilyapsizmi, shu sababli base64 kodlashni bajarishingiz mumkin?
qo'shib qo'ydi muallif mabs, manba
Kechirasiz, bu chuqurroqdir. NativeScript ning qabul qilish va XMLHttpRequest o'zaro ma'lumotlar uchun qo'llab-quvvatlamaydi: github.com/NativeScript/NativeScript/issues/570 Backend nazorat qilyapsizmi, shu sababli base64 kodlashni bajarishingiz mumkin?
qo'shib qo'ydi muallif mabs, manba
Ha, menimcha, bu mening busissness rivojlanish, shuning uchun bu (python, encodig base64, ikki satr kod, LOL) hal bo'ladi, deb o'ylayman ... lekin bu echim juda ko'p emas ... rahmat!
qo'shib qo'ydi muallif Nico, manba
Ha, menimcha, bu mening busissness rivojlanish, shuning uchun bu (python, encodig base64, ikki satr kod, LOL) hal bo'ladi, deb o'ylayman ... lekin bu echim juda ko'p emas ... rahmat!
qo'shib qo'ydi muallif Nico, manba
Ha, menimcha, bu mening busissness rivojlanish, shuning uchun bu (python, encodig base64, ikki satr kod, LOL) hal bo'ladi, deb o'ylayman ... lekin bu echim juda ko'p emas ... rahmat!
qo'shib qo'ydi muallif Nico, manba

6 javoblar

NativeScript ning http modulida getImage (...) funksiyasi mavjud.

Men buni o'zim sinab ko'rmadim, lekin siz o'zingizning shaxsiy xizmatingizdan rasmlarni yuklash uchun uni ishlatishingiz kerak deb o'ylayman:

http://docs.nativescript.org/api-reference/modules/ http .html # getimage

Ogohlantirish: getImage (...) bir URL -yoki yoki HttpRequestOptions -objectni oladi.

I suggest creating a pipe for it, like the one I wrote for image-cache: https://gist.github.com/m-abs/9e640e5805a21a842d55e02b291147c5

0
qo'shib qo'ydi
Men tushunganimdek, ha :) Umid qilamanki, u siz uchun ishlaydi.
qo'shib qo'ydi muallif mabs, manba
rahmat! Buni sinab ko'rmoqdamiz, getImage ({headers: headers, url: url}) to'g'ri?
qo'shib qo'ydi muallif Nico, manba

NativeScript ning http modulida getImage (...) funksiyasi mavjud.

Men buni o'zim sinab ko'rmadim, lekin siz o'zingizning shaxsiy xizmatingizdan rasmlarni yuklash uchun uni ishlatishingiz kerak deb o'ylayman:

http://docs.nativescript.org/api-reference/modules/ http .html # getimage

Ogohlantirish: getImage (...) bir URL -yoki yoki HttpRequestOptions -objectni oladi.

I suggest creating a pipe for it, like the one I wrote for image-cache: https://gist.github.com/m-abs/9e640e5805a21a842d55e02b291147c5

0
qo'shib qo'ydi
Men tushunganimdek, ha :) Umid qilamanki, u siz uchun ishlaydi.
qo'shib qo'ydi muallif mabs, manba
rahmat! Buni sinab ko'rmoqdamiz, getImage ({headers: headers, url: url}) to'g'ri?
qo'shib qo'ydi muallif Nico, manba

NativeScript ning http modulida getImage (...) funksiyasi mavjud.

Men buni o'zim sinab ko'rmadim, lekin siz o'zingizning shaxsiy xizmatingizdan rasmlarni yuklash uchun uni ishlatishingiz kerak deb o'ylayman:

http://docs.nativescript.org/api-reference/modules/ http .html # getimage

Ogohlantirish: getImage (...) bir URL -yoki yoki HttpRequestOptions -objectni oladi.

I suggest creating a pipe for it, like the one I wrote for image-cache: https://gist.github.com/m-abs/9e640e5805a21a842d55e02b291147c5

0
qo'shib qo'ydi
Men tushunganimdek, ha :) Umid qilamanki, u siz uchun ishlaydi.
qo'shib qo'ydi muallif mabs, manba
rahmat! Buni sinab ko'rmoqdamiz, getImage ({headers: headers, url: url}) to'g'ri?
qo'shib qo'ydi muallif Nico, manba

Bu qanday, ammo nativescript/angular2 usulida emas, bu django yordamida o'xshash orqa qismdir.

import base64
import mimetypes
from django.http import FileResponse, HttpResponse

    def download(request):

        """
        your way to get your file and original_filename
        """

        type, encoding = mimetypes.guess_type(original_filename)
        if type is None:
            type = 'application/octet-stream'

        if request.GET.get('base64'):
            response =  HttpResponse("data:"+type+";base64,"+base64.b64encode(fobject.read()))
        else:
            response =  FileResponse(fobject)
            response['Content-Type'] = type
            response['Content-Length'] = str(os.stat(file_path).st_size)
            if encoding is not None:
                response['Content-Encoding'] = encoding
        """
        ETC ETC ETC
        """
        return response
0
qo'shib qo'ydi

Bu qanday, ammo nativescript/angular2 usulida emas, bu django yordamida o'xshash orqa qismdir.

import base64
import mimetypes
from django.http import FileResponse, HttpResponse

    def download(request):

        """
        your way to get your file and original_filename
        """

        type, encoding = mimetypes.guess_type(original_filename)
        if type is None:
            type = 'application/octet-stream'

        if request.GET.get('base64'):
            response =  HttpResponse("data:"+type+";base64,"+base64.b64encode(fobject.read()))
        else:
            response =  FileResponse(fobject)
            response['Content-Type'] = type
            response['Content-Length'] = str(os.stat(file_path).st_size)
            if encoding is not None:
                response['Content-Encoding'] = encoding
        """
        ETC ETC ETC
        """
        return response
0
qo'shib qo'ydi

Bu qanday, ammo nativescript/angular2 usulida emas, bu django yordamida o'xshash orqa qismdir.

import base64
import mimetypes
from django.http import FileResponse, HttpResponse

    def download(request):

        """
        your way to get your file and original_filename
        """

        type, encoding = mimetypes.guess_type(original_filename)
        if type is None:
            type = 'application/octet-stream'

        if request.GET.get('base64'):
            response =  HttpResponse("data:"+type+";base64,"+base64.b64encode(fobject.read()))
        else:
            response =  FileResponse(fobject)
            response['Content-Type'] = type
            response['Content-Length'] = str(os.stat(file_path).st_size)
            if encoding is not None:
                response['Content-Encoding'] = encoding
        """
        ETC ETC ETC
        """
        return response
0
qo'shib qo'ydi
Angular Uzbekistan
Angular Uzbekistan
107 ishtirokchilar

Guruh Angular bo'yicha muloqot qilish uchun ochilgan Sizni qiziqtirsa: @nodejs_uz @react_uz @angular_uz @yiiframework_uz @js_uzb @typescript_uzb @vuejs_uz @ngTashkent @laravel_uz @uzdevgroup Ish o'rinlari @UzDev_jobs

ngTashkent
ngTashkent
77 ishtirokchilar

Правила просты: 1. Не хамить 2. Не хейтить 3. Реакт не нужен Ссылки: https://t.me/angular_ru - старший брат https://t.me/angular_uz - ангулар на узбекском @js_uzb @vuejs_uz @react_uz @nodejs_uz @yiiframework_uz @uzdevgroup @UzDev_Jobs @tasdev_talks