uppy
uppy copied to clipboard
Get the source file name including directory when uploading from google drive
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
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:
https://github.com/transloadit/uppy/blob/b22a812db3a5e2a05c68a0f28d80c3e329f127bf/packages/%40uppy/companion/src/server/provider/drive/index.js#L31-L52
Would you be willing to investigate and contribute a PR?
cc @mifi
Thanks @Murderlon , for your response I will check with my peers for the above solution.
I think this has been implemented in #4537
Think so!