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

picker doesn't return type for PDF #56

Closed
Mactub07 opened this issue Aug 11, 2017 · 4 comments
Closed

picker doesn't return type for PDF #56

Mactub07 opened this issue Aug 11, 2017 · 4 comments

Comments

@Mactub07
Copy link

Mactub07 commented Aug 11, 2017

I've tried to download PDF file from ICloud and got
DocumentPicker.show({
filetype: ['com.adobe.pdf'],
}, (error, res) => {
const allowedType = ["image/jpeg", "image/png", "pdf"];

            if (allowedType.includes(res.type) && res.fileSize < 2000000) {
                const Name = "Document " + res.fileName.split(".")[0];

                // todo GuidKey should gets from uploadFile endpoint response
                const file = { Name, GuidKey: "" };
                this.props.uploadDocument(res.uri, res.type, res.fileName, { Code: this.props.onBoardingCode});

                // this.props.addFileToCurrentDocument(file);
            } else if (!allowedType.includes(res.type)) {
                Alert.alert("You can upload only jpeg, png or pdf");
            } else {
                Alert.alert("You can not upload a file larger than two megabytes");
            }
        });

If print res I've got fileName, fileSize and uri, but not "type" is there a bug?
React-native :0.43
Platform : IOS

@dantman
Copy link
Collaborator

dantman commented Sep 20, 2017

@Elyx0
Copy link
Collaborator

Elyx0 commented Sep 27, 2017

Yeah that sucks...

@dantman
Copy link
Collaborator

dantman commented Oct 13, 2017

I found a solution to this. hfsTypeCode doesn't work, but Cocoa does have an API for interacting Apple's their database of UTIs and can be used to ask for the appropriate UTI for a file extension and then a mime type for a UTI.

7a7ee8e

@vonovak
Copy link
Collaborator

vonovak commented Apr 17, 2020

closing as resolved, see message above

@vonovak vonovak closed this as completed Apr 17, 2020
@react-native-documents react-native-documents locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants