Skip to content

Conversation

@MaximBelov
Copy link

No description provided.

@priyaa05
Copy link

priyaa05 commented Mar 10, 2023

Hi @MaximBelov ,

After the latest Pull request for refactoring is merged, I can't see the data field in ChooserResult.

Previously we were using the data field to get the data array as blob and post it as FormData to our Http endpoint. This doesn't work anymore. Can you please advise on how we use this from now on. Can the documentation be updated.

image

Thanks,
Priyanka

@MaximBelov
Copy link
Author

@priyaa05
Copy link

Hi @MaximBelov ,
I tried to refactor my code, but still having issues.

I included these in pacakge.json file
"@awesome-cordova-plugins/chooser": "^6.3.0"
"cordova-plugin-chooser": "^1.3.2",

In the code it shows me latest object/data types for ChooserResult, but when I do 'ionic build' and 'npx cap sync android' and run the app in phone, the debugger shows the old data types for ChooserResult. So when I'm accessing file.mimeType, it says mimeType is not defined and its not there in the ChooserResult object.

In the npm site it says it was last published 3 years ago.
image

Thanks,
Priyanka

@MaximBelov
Copy link
Author

Hi
@priyaa05

Version of cordova-plugin-chooser from npm is outdated.

Try fixed version from github

"cordova-plugin-chooser": "git+https://github.com/MaximBelov/cordova-plugin-chooser.git#1.4.0-custom",

@priyaa05
Copy link

Hi @MaximBelov ,

After I changed package.json to use this new version, I can see the new data types in the debug mode.

But we still need to get blob data , as we are using Form Data and we don't want to add another plugin for http which is advanced http just for uploading files.

I tried another method to get blob data using File.ReadAsArrayBuffer() from cordova-plugin-file, but this method doesn't resolve and it doesn't return the blob data.

image

If we can add backward compatibility and add just the fileData field which has blob data to Chooser plugin, that would be great. It would save us a lot of time.

Thanks,
Priyanka

let resources = try url.resourceValues(forKeys:[.fileSizeKey])
let fileSize = resources.fileSize!
print ("\(fileSize)")
if(fileSize > maxFileSize){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is missing a != 0 check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants