Remove files
Delete an object uploaded to S3 by using Amplify.Storage.remove
:
With StoragePath
1let removedObject = try await Amplify.Storage.remove(path: .fromString("public/example/path"))2print("Deleted \(removedObject)")
1let sink = Amplify.Publisher.create {2 try await Amplify.Storage.remove(path: .fromString("public/example/path"))3}.sink {4 if case let .failure(error) = $0 {5 print("Failed: \(error)")6 }7}8receiveValue: { removedObject in9 print("Deleted \(removedObject)")10}
With Key (Deprecated)
1let removedKey = try await Amplify.Storage.remove(key: "myKey")2print("Deleted \(removedKey)")
1let sink = Amplify.Publisher.create {2 try await Amplify.Storage.remove(key: "myKey")3}.sink {4 if case let .failure(error) = $0 {5 print("Failed: \(error)")6 }7}8receiveValue: { removedKey in9 print("Deleted \(removedKey)")10}