Tiny Drive 是一款基于云的资产管理和存储的高级 TinyMCE 插件。Tiny Drive 允许您的用户在 TinyMCE 中上传、管理和使用文件。
若要获取在 TinyMCE 之外使用 Tiny Drive 的文档,请访问:Tiny Drive 文档。
此插件仅适用于 Tiny Cloud 用户。
Tiny Drive 功能
Tiny Drive 支持以下文件格式、扩展名和存储选项:
| 功能 | 值 |
|---|---|
文件上传 | 通过拖放或使用上传按钮上传文件。若与 TinyMCE 集成,在 TinyMCE 中通过拖放或复制粘贴添加的文件将使用 Tiny Drive 上传 |
CDN | 文件存储在 S3 中,并通过 Amazon 的 CDN 访问,以便在全球范围内快速交付 |
文件管理 | 移动、复制、删除和整理您的在线文件存储 |
搜索 | 搜索您的文件库,为您常用的文件添加星标以便快速访问 |
预览 | 在选择要使用的内容之前预览图片和视频 |
集成 | 与 Google Drive 和 Dropbox 集成,允许您通过 Tiny Drive 从这些系统导入文件 |
存储和带宽配额根据您的 Tiny Cloud 计划而有所不同。
交互示例
HTML
<textarea id="drive">
<p><img style="display: block; margin-left: auto; margin-right: auto;" title="Tiny Logo" src="https://www.tiny.cloud/docs/tinymce/latest/_images/logos/android-chrome-256x256.png" alt="TinyMCE Logo" width="128" height="128"></p>
<h2 style="text-align: center;">Welcome to the Tiny Drive plugin demo!</h2>
<p>To open the <strong>Tiny Drive</strong> file manager:</p>
<ul>
<li>Click the "<strong>Insert file</strong>" (<img src="../_images/icons/browse.svg" alt="browse files icon" width="18" height="18" />) toolbar button, or</li>
<li>Select the "<img src="../_images/icons/browse.svg" alt="browse files icon" width="18" height="18" /> File" menu item (<strong>Insert > File</strong>)</li>
</ul>
<p>Things to try:</p>
<ul>
<li>To add another file to the Tiny Drive, use the <img src="../_images/icons/plus.svg" alt="plus symbol icon" width="18" height="18" /> button</li>
<li>To insert an image from the drive, click the image name</li>
<li>To view more options, click the <img src="../_images/icons/image-options.svg" alt="horizontal ellipses icon" width="18" height="18" /> at the end of the file or folder row.</li>
</ul>
</textarea>CSS
button.olark-launch-button {
z-index: 1 !important;
}
.menu {
z-index: 1000 !important;
}JS
tinymce.init({
selector: 'textarea#drive',
plugins: 'image media link tinydrive code editimage lists',
height: 600,
tinydrive_token_provider: 'URL_TO_YOUR_TOKEN_PROVIDER',
toolbar: 'insertfile image link | code',
menu: {
insert: { title: 'Insert', items: 'image link media insertfile' },
}
});上传文件 URL
每个文件的 URL 格式为 https://drive.tiny.cloud/1/{your-api-key}/{uuid},在文件上传时生成。如果文件被移动或重命名,它将仍然具有相同的唯一 URL,因此使用 Tiny Drive 对文件进行重构不会影响 URL。删除文件会将该 URL 标记为未使用,该 URL 将不再有效。
基于 JSON Web Token (JWT) 的身份验证
某些 Tiny 服务需要设置 JSON Web Token (JWT) 身份验证。这使得 Tiny Cloud 能够验证终端用户是否有权访问特定功能。JWT 是 Web 服务的一种常见授权解决方案,详细信息可在 https://jwt.io/ 网站上查阅。有关设置 JWT 身份验证的信息,请参阅JWT 身份验证部分。
用户特定的文件访问
Tiny Drive 允许开发人员设置用户特定的目录,因此用户只能看到他们自己的文件。这可以通过将 https://claims.tiny.cloud/drive/root 自定义 JSON Web Token (JWT) 声明设置为 Tiny Account 内的一个路径来实现。当用户使用带有该声明的 JWT 密钥访问 Tiny Drive 时,此路径将自动构建。用户只能看到并管理该目录内的文件。
安全和性能
Tiny 深知在云存储方面,安全是首要考虑的问题。由于用户资产在 Tiny Drive 和 Tiny Cloud 之间传输,Tiny Drive 使用 Tiny Account API 密钥和 JSON Web Token (JWT) 来对每个数据事务进行身份验证。
文件类型
有一组固定的可上传的文件扩展名(格式),它们被归入以下文件类型类别中。某些文件格式被阻止,因为它们可能会带来安全问题。
documentdoc, xls, ppt, pps, docx, xlsx, pptx, pdf, rtf, txt, key, pages, numbers
audiowav, wave, mp3, ogg, oga, ogx, ogm, spx, opus
videomp4, m4v, ogv, webm, mov
imagegif, jpeg, jpg, jpe, jfi, jif, jfif, pjpeg, pjp, png, tif, tiff, bmp, webp, avif, apng
archivezip
Starter projects
为了快速入门并了解 Tiny Drive 的工作原理,Tiny 建议尝试 GitHub 上的其中一个 Starter projects 来设置 Tiny Drive。
这些 Starter projects 有各自的流程来使 Tiny Drive 启动并运行。选择一个熟悉语言的 Starter project,然后按照步骤设置 Tiny Drive。这些链接将引导你访问所选 Starter project 的 GitHub 页面,在那里可以查看源代码。
