空图片已上传 [英] Empty Image is uploadded

查看:101
本文介绍了空图片已上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图像上传到wordpress正在上传空白图像

Image Upload to wordpress is uploading empty image

我正在处理使用wordpress API的移动应用程序.我的应用程序使用Nativescript-Vue框架.我需要使用远程WP-API将多个图像上传到wordpress.

I am working on a mobile application consumes wordpress API. My application uses Nativescript-Vue Framework. I need to upload multiple images to wordpress using remote WP-API.

        var data=[];
        const params = new FormData();
        //params.append('file', this.value);

         this.product.images.forEach(i => {
           params.append('file',i.src);
           console.log(i.src);
         });

        const axiosInstance = axios.create({
          baseURL: 'https://mah.ttawor.com/wp-json/wp/v2/',
          timeout: 5000,
          headers: {
            Authorization: this.auth_token,
            'content_type':'multipart/form-data' ,
            'Content-Disposition':`attachment; filename="product.jpg"`
          },
        });

        if(this.product.images.length === 0) return;


        axiosInstance.post('media',params)
          .then(response => {
            //console.log(response)
          })
          .catch(err => {
            console.log(err)
          })
    }

不幸的是,Word Press收到一个空白图像.任何解决方案,我都尝试过nativescript-background-http.这也不起作用,在使用wordpress的oauth中存在很多问题

Unfortunately, Word Press receives an empty image. Any solution, i have tried nativescript-background-http.That does not work either, it has a lot of problems with oauth with wordpress

推荐答案

截至今天,{N}不支持开箱即用的多部分数据上传.您可以按照Github上的打开功能请求进行进一步的更新.

As of today, {N} doesn't support multi-part data upload out of the box. You may follow on the open feature request on Github for further updates.

建议的解决方法是同时使用 nativescript-background-http 插件.

It's recommended workaround is to use nativescript-background-http plugin meanwhile.

tns plugin add nativescript-background-http

这篇关于空图片已上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆