Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate directory tree from box provider #4423

Closed
2 tasks done
antonpetrov145 opened this issue Apr 20, 2023 · 14 comments
Closed
2 tasks done

Recreate directory tree from box provider #4423

antonpetrov145 opened this issue Apr 20, 2023 · 14 comments
Assignees
Labels

Comments

@antonpetrov145
Copy link

antonpetrov145 commented Apr 20, 2023

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

I'm using Uppy and tus as a standalone server, which is connected to Dashboard.

Create a directory tree in box like so:

/Parent_dir
   /child_dir
       file

When uploading local directory tree, the problem is not present

Expected behavior

When selected upload Parent_dir recreate the file directory to destination.

Actual behavior

When uploading with companion and dashboard the Parent_dir I receive no files found.

@mifi
Copy link
Contributor

mifi commented Apr 24, 2023

so the problem is that if you select a directory, Uppy will not select any files inside of it?

@antonpetrov145
Copy link
Author

it will select it if there is, but if there is a subdirectory it shows the error, my idea is to use it with a similar functionality as in tusd - if I send a tree to it, the tree is recreated to the destination

@arturi
Copy link
Contributor

arturi commented Apr 26, 2023

So it's a feature request, you'd like to re-create directory tree on the destination server, after upload? We have file.meta.relativePath https://uppy.io/docs/uppy/#addfilefile for local files, we could pass it from cloud providers if they support it:

getTagFile (file) {
const tagFile = {
id: file.id,
source: this.plugin.id,
data: file,
name: file.name || file.id,
type: file.mimeType,
isRemote: true,
meta: {},
body: {
fileId: file.id,
},
@mifi

@mifi
Copy link
Contributor

mifi commented Apr 26, 2023

correct me if i'm wrong but i think the problem is that there is an error thrown and files do not even get uploaded if there is a subdirectory. If so, then i would say it's a bug, not feature request

@antonpetrov145
Copy link
Author

antonpetrov145 commented Apr 26, 2023

You are both correct. When I try to upload directory that has subdirectory and and file in the sub I get error, the end result would be to get the full tree in the destination. So it's a feature request + bug?

Can we get the directory tree from provider and sent to tusd?

@antonpetrov145
Copy link
Author

antonpetrov145 commented Apr 28, 2023

So I've added this to the list function in /server/provider/box/index.js file

async function list ({ directory, query, token}) {
  const rootFolderID = '0';
  const response = await getClient({ token }).get(`folders/${directory || rootFolderID}/items`, { searchParams: { fields: BOX_FILES_FIELDS, offset: query.cursor }, responseType: 'json' });
  const items = response.body.entries;
  let files = [];
  let folders = [];

  for (let i = 0; i < items.length; i++) {
    const item = items[i];
    if (item.type === 'folder') {
      const folderContent = await list({ directory: item.id, query, token});
      files = files.concat(folderContent.files);
      folders = folders.concat(folderContent.folders);
    } else {
      files.push(item);
    }
  }

  return { files, folders };
}

and changed const items = [...res.files, ...res.folders] in /server/provider/box/adapter.js file
Where am I mistaken, as this doesn't show the directories?

@dschmidt
Copy link
Contributor

Is this fixed with #4537?

@antonpetrov145
Copy link
Author

@dschmidt I'm trying to test, but getting these errors when I try to build the docker container:

src/server/helpers/request.js(2,1): error TS9006: Declaration emit for this file requires using private name 'StaticEventEmitterOptions' from module '"events"'. An explicit type annotation may unblock declaration emit.
src/server/helpers/request.js(2,1): error TS9006: Declaration emit for this file requires using private name '_DOMEventTarget' from module '"events"'. An explicit type annotation may unblock declaration emit.
src/server/helpers/request.js(2,1): error TS9006: Declaration emit for this file requires using private name '_NodeEventTarget' from module '"events"'. An explicit type annotation may unblock declaration emit.

@dschmidt
Copy link
Contributor

I think I've seen that, I had no time to properly debug it and figure out why it started to happen for us, but iirc this was my workaround: owncloud@538f172

@antonpetrov145
Copy link
Author

@dschmidt

I think I've seen that, I had no time to properly debug it and figure out why it started to happen for us, but iirc this was my workaround: owncloud@538f172

Nice, this solved my deploy problem. Thank you for that.

I still can't recreate the tree from box into my destination, do you think there is a way to add the path as a string in the metadata object before upload?

For instance here for tus:

metadata: {
          folder: path from provider <-- I need this and will process it with tus afterward
          filename: this.uploadFileName,
          filetype: this.options.metadata.type,
          ...this.options.metadata,
        },

@mifi
Copy link
Contributor

mifi commented Aug 17, 2023

Hi, which version are you on? Can't you find relativePath in the metadata?

@antonpetrov145
Copy link
Author

antonpetrov145 commented Aug 17, 2023

@mifi Companion is latest release from here, Dashboard is CDN version v3.13.1 from here
https://uppy.io/docs/dashboard/#install

@dschmidt
Copy link
Contributor

@mifi Companion is latest release from here, Dashboard is CDN version v3.13.1 from here https://uppy.io/docs/dashboard/#install

Although the relativePath is a frontend feature, you need to make sure the frontend libs are up to date as well - Companion is probably not even that important

@antonpetrov145
Copy link
Author

@mifi @dschmidt Thank you both for your time and efforts, I needed to update the version of dashboard too. Now I see the absolutePath and relativePath in the metadata. This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants