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

Get the source file name including directory when uploading from google drive #3621

Closed
100mi opened this issue Apr 5, 2022 · 4 comments
Closed
Labels

Comments

@100mi
Copy link

100mi commented Apr 5, 2022

Can uppy save the folder location of file that is picked from google drive and saves it in meta if the response is success ?
With a sample folder structure in google drive :

- Parent1
    - child1
	    - output.xlsx
	    - output1.xlsx
    - child2
	    - output.xlsx
	    - output1.xlsx

Once we upload the file the response turn out to be something like :

{
        "source": "GoogleDrive",
        "id": "uppy-output/xlsx-1e-application/vnd.openxmlformats-officedocument.spreadsheetml.sheet-1024",
        "name": "output.xlsx",
        "extension": "xlsx",
        "meta": {
            "name": "output.xlsx",
            "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        },
        "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        "data": {
            "isFolder": false,
            "icon": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet",
            "name": "output.xlsx",
            "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "id": "1wjdFf6kOE48GhXcx6rHP_TI9uzR8tTvAUGN-7LJbkIU",
            "thumbnail": "https://docs.google.com/feeds/vt?gd=true&id=1wjdFf6kOE48GhXcx6rHP_TI9uzR8tTvAUGN-7LJbkIU&v=1&s=AMedNnoAAAAAYkxj8QNhqf1n8qCTv0v41M9MI0RO7IFf&sz=s220",
            "requestPath": "1wjdFf6kOE48GhXcx6rHP_TI9uzR8tTvAUGN-7LJbkIU",
            "modifiedDate": "2022-02-22T21:35:56.496Z",
            "size": 1024,
            "custom": {
                "isSharedDrive": false
            }
        },
        "progress": {
            "uploadStarted": 1649166323507,
            "uploadComplete": true,
            "percentage": 100,
            "bytesUploaded": 4910,
            "bytesTotal": 4910,
            "postprocess": null
        },
        "size": 1024,
        "isRemote": true,
        "remote": {
            "companionUrl": "//companion.uppy.io",
            "url": "//companion.uppy.io/drive/get/1wjdFf6kOE48GhXcx6rHP_TI9uzR8tTvAUGN-7LJbkIU",
            "body": {
                "fileId": "1wjdFf6kOE48GhXcx6rHP_TI9uzR8tTvAUGN-7LJbkIU"
            },
            "providerOptions": {
                "companionUrl": "//companion.uppy.io",
                "provider": "drive",
                "pluginId": "GoogleDrive"
            },
            "providerName": "Drive"
        },
        "serverToken": "9851566a-8642-446a-bff2-03bc19fd85e1",
        "response": {
            "uploadURL": "https://tusd.tusdemo.net/files/31e544b40995de482ca5b7d35f6fc5b5+VhlEZNjYKgTrDk0MWP4dABaNzIglQC6_f.rX6YrApreW.dv1SxhGB1gucVKDtxPa8vojLK44Pftwnqk0pdOeGRtFEM4j6qDbulwJqhIT.RKoeim2SLPo180tV9w9NrRN"
        },
        "uploadURL": "https://tusd.tusdemo.net/files/31e544b40995de482ca5b7d35f6fc5b5+VhlEZNjYKgTrDk0MWP4dABaNzIglQC6_f.rX6YrApreW.dv1SxhGB1gucVKDtxPa8vojLK44Pftwnqk0pdOeGRtFEM4j6qDbulwJqhIT.RKoeim2SLPo180tV9w9NrRN",
        "isPaused": false
    }

With the above folder structure , Uppy only seems to provide name of the file as name which is output1.csv and so on , which in case is repetative , hence would it be possible to get the directory name along with other meta values such as dir1/output1.csv

@100mi 100mi changed the title Provide file location if response is success Get the source file path including directory when uploading from google drive Apr 5, 2022
@100mi 100mi changed the title Get the source file path including directory when uploading from google drive Get the source file name including directory when uploading from google drive Apr 5, 2022
@Murderlon
Copy link
Member

At least with local files it's possible with FileSystemEntry:

uppy.addFile({
  name: 'my-file.jpg', // file name
  type: 'image/jpeg', // file type
  data: blob, // file blob
  meta: {
    // optional, store the directory path of a file so Uppy can tell identical files in different directories apart.
    relativePath: webkitFileSystemEntry.relativePath,
  },
  source: 'Local', // optional, determines the source of the file, for example, Instagram.
  isRemote: false, // optional, set to true if actual file is not in the browser, but on some remote server, for example,
  // when using companion in combination with Instagram.
})

For remote files from Google Drive I'm pretty sure we could add it here:

function adaptData (listFilesResp, sharedDrivesResp, directory, query, showSharedWithMe) {
const adaptItem = (item) => ({
isFolder: adapter.isFolder(item),
icon: adapter.getItemIcon(item),
name: adapter.getItemName(item),
mimeType: adapter.getMimeType(item),
id: adapter.getItemId(item),
thumbnail: adapter.getItemThumbnailUrl(item),
requestPath: adapter.getItemRequestPath(item),
modifiedDate: adapter.getItemModifiedDate(item),
size: adapter.getItemSize(item),
custom: {
isSharedDrive: adapter.isSharedDrive(item),
imageHeight: adapter.getImageHeight(item),
imageWidth: adapter.getImageWidth(item),
imageRotation: adapter.getImageRotation(item),
imageDateTime: adapter.getImageDate(item),
videoHeight: adapter.getVideoHeight(item),
videoWidth: adapter.getVideoWidth(item),
videoDurationMillis: adapter.getVideoDurationMillis(item),
},
})

Would you be willing to investigate and contribute a PR?

cc @mifi

@100mi
Copy link
Author

100mi commented Apr 11, 2022

Thanks @Murderlon , for your response I will check with my peers for the above solution.

@arturi arturi removed the Triage label Jul 6, 2023
@dschmidt
Copy link
Contributor

I think this has been implemented in #4537

@mifi
Copy link
Contributor

mifi commented Jul 22, 2023

Think so!

@mifi mifi closed this as completed Jul 22, 2023
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

5 participants