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

Support iOS assets-library url #62

Merged
merged 7 commits into from
Feb 8, 2018
Merged

Conversation

StevePotter
Copy link
Contributor

@StevePotter StevePotter commented Feb 8, 2018

If you upload a file directly from the photo library, you previously had to copy the asset into a temporary file, which some picker libraries apparently don't support. Now the upload library supports that natively.

I did it by just copying the asset to a file. iOS had no support for directly uploading them. The best approach I found, and I researched a bunch, was from https://stackoverflow.com/questions/33278540/phasset-afnetworking-upload-multiple-videos

I took advantage of ObjC dispatch groups to make the actual implementation pretty straightforward.

Copy link
Contributor

@TSMMark TSMMark left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀

PHAssetResource *assetResource = [[PHAssetResource assetResourcesForAsset:asset] firstObject];
NSString *pathToWrite = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]];
NSURL *pathUrl = [NSURL fileURLWithPath:pathToWrite];
fileURI = pathUrl.absoluteString;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the format or value of fileURI after being set to pathUrl.absoluteString;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

file://blahblahblah

@StevePotter StevePotter merged commit 4513d2b into master Feb 8, 2018
@StevePotter StevePotter deleted the ios-asset-library-upload branch February 8, 2018 15:16
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.

2 participants