创建plist下载,无需创建文件 [英] Create plist download, without creating a file

查看:54
本文介绍了创建plist下载,无需创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试下载我的IOS应用程序的链接。众所周知,这需要一个.plist文件,其中包含有关该应用程序的所有信息。我想制作下载链接,而不必创建文件。我试过这样做,但它不起作用。我想也许是因为链接包含url,它只指向它自己的XML。有任何想法吗? 

我使用过这个库:https://github.com/TooTallNate/plist.js





我尝试过:



 Pastebin:https://pastebin.com/0fTqweYP 

解决方案

Quote:

 var plistBuildAndParsed = plist.build(plist.parse(plistData)); 



基于该GitHub项目的文档 [ ^ ],所有这一行将把你的plist XML转换为JSON,然后将JSON转换回等效的plist XML。



如果你调试你的代码,你可能会看到你试图启动的URL看起来像:

 itms-services://?action = download-manifest& url =<?xml version =1.0... 



显然,plist XML文件的内容不是有效的URL。



在支持的浏览器中,您可以组合 URL.createObjectURL [ ^ ],带有 Blob [ ^ ]生成XML文件的URL。不幸的是,iOS上似乎不支持Blob API。



您可以尝试 a 数据: URI [ ^ ]而是:

  var  plistUrl =   data:text / xml,  + encodeURIComponent(plistBuildAndParsed); 
link.setAttribute( href itms-services://?action = download-manifest& url = + encodeURIComponent(plistUrl));


I am trying to make a download link to my IOS app. This, as we all knows, requires a .plist file with all the informations regarding the app. I would like to make the download link, without having to create a file. I have tried to do it, but it does not work. I maybe think, it is because the link contains "url", which just points to the XML it selfs. Any ideas?

I have used this library: https://github.com/TooTallNate/plist.js



What I have tried:

Pastebin: https://pastebin.com/0fTqweYP

解决方案

Quote:

var plistBuildAndParsed = plist.build(plist.parse(plistData));


Based on a quick read of the documentation for that GitHub project[^], all that line is going to do is convert your plist XML to JSON, then convert the JSON back to the equivalent plist XML.

If you debug your code, you'll probably see that the URL you're trying to launch looks something like:

itms-services://?action=download-manifest&url=<?xml version="1.0" ...


Obviously, the contents of the plist XML file is not a valid URL.

In a supported browser, you could combine URL.createObjectURL[^] with a Blob[^] to generate a URL for your XML file. Unfortunately, the Blob API doesn't seem to be supported on iOS.

You could try a data: URI[^] instead:

var plistUrl = "data:text/xml," + encodeURIComponent(plistBuildAndParsed);
link.setAttribute("href", "itms-services://?action=download-manifest&url=" + encodeURIComponent(plistUrl));


这篇关于创建plist下载,无需创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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