Closed NTJ3 closed 2 years ago
Do you consider me a magus? I can't say anything without seeing a reproducible demo.
Do you consider me a magus? I can't say anything without seeing a reproducible demo.
@RobinBobin
GoogleSignin.addScopes({
scopes: [
'https://www.googleapis.com/auth/drive.readonly',
],
}).then(async (val) => {
const gdrive = new GDrive();
gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken
const filesRes = await gdrive.files.list({
fileds: 'files/mimeType',
q: new ListQueryBuilder()
.e('mimeType', 'application/pdf')
.or()
.e('mimeType', 'application/msword')
.or()
.e(
'mimeType',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
),
const gdrive = new GDrive();
const queryParams = {
// mimeType: item.mimeType,
alt: 'media',
};
gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken;
// gdrive.permissions.create(item.id, queryParams);
gdrive.files
.get(item.id, queryParams)
.then((res) => {
console.log(res);
const fileType =
item.name.endsWith('.docx') || item.name.endsWith('.doc')
? 'word'
: item.name.endsWith('.pdf')
? 'pdf'
: '';
const imagePath = `${RNFS.DownloadDirectoryPath}/${moment().valueOf()}.${fileType}`;
RNFS.downloadFile({
fromUrl: res.url,
toFile: imagePath,
})
Are your scopes sufficient for downloading files?
You don't need rnfs to be able to download files. Have a look at my sample project linked in the docs.
Yes scopes are correct.
Are your scopes sufficient for downloading files?
You don't need rnfs to be able to download files. Have a look at my sample project linked in the docs.
@RobinBobin Yes scopes are correct, I can't download files implementation in your example project. Can you share the same if you have done il.
My requirement is to download files from Google Drive via your package is it possible?
Yes, my package certainly can be used to download files.
The example project works for me. What problems are you facing when using it to download a file?
@RobinBobin When I'm accessing url from
gdrive.files
.get(item.id, queryParams)
it gives me this below error
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
Can we have google meet?
I think I'll be unavailable for a meet today.
Are you saying you launched my sample project and file downloading is giving you an error?
No, I'm using url from below res
gdrive.files
.get(item.id, queryParams)
Try using my sample project. If it works for you, copy the code.
@RobinBobin I tried your sample project I can't find code for download file. Could you pls share it if you know already?
How about this?
@RobinBobin This also didn't work.. It gives me Uint8Array but it's not convertible to any other form.
That did work as expected. You can google to understand how to convert Uint8Array to js array.
Yes, I did follow that only, That should return the file path. Not an Uint8Array
What method should return a file path in your opinion?
@RobinBobin This is not working in iOS
const tokens = await GoogleSignin.getTokens();
const gdrive = new GDrive();
gdrive.accessToken = tokens.accessToken;
gdrive.fetchTimeout = 4000;
gdrive.files.getBinary(item.id)
ERRR
ExceptionsManager.js:149 TypeError: Cannot read properties of undefined (reading 'length')
at getLens (index.js:23:17)
at toByteArray (index.js:55:14)
at reader.onload (utils.ts:16:47)
at FileReader.dispatchEvent (event-target-shim.js:818:35)
at FileReader._setReadyState (FileReader.js:76:14)
at FileReader.js:101:14
at tryCallOne (core.js:37:12)
at core.js:123:15
at JSTimers.js:248:18
at _callTimer (JSTimers.js:112:7)
Does the sample project work in iOS?
I'll close it, since it's been inactive for a while.
@RobinBobin getting this error while downloading files from the drive.