我刚刚了解到sudo apt install gupnp-tools
在 Ubuntu 中我可以执行 UPNP 发现:
$ gssdp-discover
Using network interface wlp3s0
Scanning for all resources
Showing "available" messages
...
resource available
USN: uuid:e04d4bbc-8b30-6c8c-bcbc-faafb717f98f::urn:schemas-upnp-org:service:ContentDirectory:1
Location: http://192.168.0.152:38389/deviceDescription/MediaServer
...
这里有一个命令gupnp-upload
;没有手册页,唯一的文档是:
$ gupnp-upload -h
Usage:
gupnp-upload [OPTION?] - Upload files to UPnP MediaServer
Help Options:
-h, --help Show help options
Application Options:
-t, --search-timeout=seconds Search Timeout
-c, --container-id=CONTAINER_ID Destination Container ID
-i, --title=TITLE Title for item
-e, --interface=INTERFACE Network interface to search MediaServer on
-u, --udn=UDN UDN of the device to upload to
我在互联网上找到的唯一使用示例是回复:如何使用rygel上传服务?:
Finally, I try to upload a picture:    $ gupnp-upload -i lo uuid:8aa83fb8-c1d8-445a-98c1-76d3d22847bf gnome-logo.png    ** (gupnp-upload:27841): CRITICAL **: Failed to find a suitable container for upload. It fails! What kind of "container" is missing?
Does it work if you use -c "DLNA_ORG.AnyContainer"? The gupnp-upload is a bit stupid and only searches the first level of containers for a container with a suitable upload-class. -c "DLNA_ORG.AnyContainer" will ask the server to find one.
因此,根据上述发现,我尝试:
$ gupnp-upload -i hello.jpg -c "DLNA_ORG.AnyContainer" uuid:e04d4bbc-8b30-6c8c-bcbc-faafb717f98f hello.jpg
File uuid:e04d4bbc-8b30-6c8c-bcbc-faafb717f98f does not exist
UPnP context created for interface wlp3s0 (192.168.0.45)
** (gupnp-upload:53645): CRITICAL **: 08:58:25.711: gupnp_control_point_new: assertion 'target' failed
(gupnp-upload:53645): GLib-GObject-WARNING **: 08:58:25.711: invalid (NULL) pointer instance
(gupnp-upload:53645): GLib-GObject-CRITICAL **: 08:58:25.711: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
** (gupnp-upload:53645): CRITICAL **: 08:58:25.711: gssdp_resource_browser_set_active: assertion 'GSSDP_IS_RESOURCE_BROWSER (resource_browser)' failed
嗯,显然事实并非如此。
那么,有人可以举个例子,说明如何上传到列为“资源可用”gupnp-upload
的 UPNP 设备吗?gssdp-discover