使用reactjs和nextjs上传文件到驱动器

发布于 2025-01-17 17:31:54 字数 438 浏览 0 评论 0原文

我正在使用这个 https://github.com/rpldy/drive-uploady 来更新文件但这个库仅显示了一个必须从本地上传文件的示例。如果我有一个文件(base64 url​​)或一个blob(我从之前从谷歌驱动器获得的pdf文件中获得的)我该如何使用它。我尝试了多种资源,但没有任何东西能给我结果。

这里: https://github.com/rpldy/react- uploady/tree/master/packages/ui/uploady

I am using this https://github.com/rpldy/drive-uploady to update files but this library only shows an example where you have to upload files from local. If i have a file (base64 url) or a blob (which i get from a pdf file i got from google drive before) how can i use this. I have tried multiple resource but no thing can give me result.

Here: https://github.com/rpldy/react-uploady/tree/master/packages/ui/uploady

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与君绝 2025-01-24 17:31:54

驱动器上的驱动器主要是用于上传的发件人。因此,您可以使用上传的大部分功能。在这种情况下, upload 上传上下文方法 -

import React from "react";
import DriveUploady, { useUploady } from "drive-uploady";


const MyButton = () => {
  const { upload } = useUploady();
  
  const onUpload = async () =>  {
  
    const myBlob = await getBlobFromSomewhere();
    
    upload(myBlob);
  };

  return <button onClick={onUpload}>Upload</button>
};

const App = () => {

  return <DriveUploady
          ...
          >
          <MyButton />
        </DriveUploady>
};

单击按钮后,这将启动上传过程。当然,您在哪里得到斑点是您的责任。

Drive-Uploady is mainly a sender for Uploady. Therefore, you are able to use most of Uploady's functionality. In this case, the upload context method -

import React from "react";
import DriveUploady, { useUploady } from "drive-uploady";


const MyButton = () => {
  const { upload } = useUploady();
  
  const onUpload = async () =>  {
  
    const myBlob = await getBlobFromSomewhere();
    
    upload(myBlob);
  };

  return <button onClick={onUpload}>Upload</button>
};

const App = () => {

  return <DriveUploady
          ...
          >
          <MyButton />
        </DriveUploady>
};

This will initiate the upload process once the button is clicked. Where you get the blob is your responsibility of course.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文