简体   繁体   English

Dropbox Open按钮如何工作?

[英]How does Dropbox Open button work?

In February 2015 Dropbox released a new feature that allowed you to trigger the local opening of a file from their web interface: https://blogs.dropbox.com/dropbox/2015/02/new-way-to-open-dropbox-files/ 2015年2月,Dropbox发布了一项新功能,允许您从其Web界面触发文件的本地打开: https//blogs.dropbox.com/dropbox/2015/02/new-way-to-open-dropbox-文件/

More information is here: 更多信息在这里:

Here is an example of the Open button visible from the context menu: 以下是从上下文菜单中可见的“打开”按钮的示例:

在此输入图像描述

And here is the brief display of the popup that is apparently connecting to the sync client: 以下是显示连接到同步客户端的弹出窗口的简要显示:

在此输入图像描述

It's clear that the Dropbox sync client must be installed, so you have some native local code running, which allows for some fancy stuff that would be impossible with just in-browser Javascript, but somehow the browser page is able to do some unexpected things: 很明显,必须安装Dropbox同步客户端,因此您运行了一些原生本地代码,这允许一些花哨的东西,只有浏览器内的Javascript是不可能的,但不知何故浏览器页面能够做一些意想不到的事情:

  1. selectively display the Open button based on information from the sync client (whether it's on and whether the file exists locally) 根据来自同步客户端的信息(是否打开以及文件是否存在于本地)有选择地显示“打开”按钮
  2. trigger, by clicking on the button, an action by the sync client (opening the file in its default app, or opening the folder in Explorer/Finder) 触发,通过单击按钮,同步客户端的操作(在其默认应用程序中打开文件,或在资源管理器/ Finder中打开文件夹)

By what technical mechanism do these two things work? 这两件事通过什么技术机制起作用?

This is just a guess, but probably something like this: 这只是猜测,但可能是这样的:

  1. The sync client knows everything about local file existence. 同步客户端知道本地文件存在的所有内容。
  2. The sync client sends that info to the sync server, so the server knows too. 同步客户端将该信息发送到同步服务器,因此服务器也知道。
  3. The Dropbox web page can then selectively show the open button. 然后,Dropbox网页可以选择性地显示打开按钮。
  4. Upon clicking the open button, the web page contacts the sync server, which in turn sends a message to the sync client to "open that file". 点击打开按钮后,网页会联系同步服务器,同步服务器又向同步客户端发送消息以“打开该文件”。
  5. The sync client opens that file. 同步客户端打开该文件。 On a Mac this would be a simple open [path] shell command. 在Mac上,这将是一个简单的open [path] shell命令。

Nothing fancy in the browser. 浏览器没什么特别的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM