Skip to content

Commit

Permalink
Add name to putImageBytes in swift
Browse files Browse the repository at this point in the history
  • Loading branch information
natsuk4ze committed Feb 4, 2024
1 parent 09b3a43 commit b7f1dff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions darwin/Classes/GalPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class GalPlugin: NSObject, FlutterPlugin {
let args = call.arguments as! [String: Any]
putMediaBytes(
bytes: (args["bytes"] as! FlutterStandardTypedData).data,
album: args["album"] as? String
album: args["album"] as? String,
name: args["name"] as! String
) { _, error in
result(error == nil ? nil : self.handleError(error: error!))
}
Expand Down Expand Up @@ -75,12 +76,14 @@ public class GalPlugin: NSObject, FlutterPlugin {
}

private func putMediaBytes(
bytes: Data, album: String?, completion: @escaping (Bool, Error?) -> Void
bytes: Data, album: String?, name: String, completion: @escaping (Bool, Error?) -> Void
) {
writeContent(
assetChangeRequest: {
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, data: bytes, options: nil)
let options = PHAssetResourceCreationOptions()
options.originalFilename = name
request.addResource(with: .photo, data: bytes, options: options)
return request
}, album: album, completion: completion
)
Expand Down

0 comments on commit b7f1dff

Please sign in to comment.