Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 2, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

ファイルの削除

Amplify Storageの最新バージョンは、S3オブジェクトをパスとして指定することをサポートしています。
S3オブジェクトを指定するには、keyの代わりにpathを使用することをお勧めします。

注: keyパラメータは非推奨であり、次のメジャーバージョンで削除される可能性があります。

Delete an object uploaded to S3 by using Amplify.Storage.remove:

With StoragePath

let removedObject = try await Amplify.Storage.remove(path: .fromString("public/example/path"))
print("Deleted \(removedObject)")
let sink = Amplify.Publisher.create {
try await Amplify.Storage.remove(path: .fromString("public/example/path"))
}.sink {
if case let .failure(error) = $0 {
print("Failed: \(error)")
}
}
receiveValue: { removedObject in
print("Deleted \(removedObject)")
}

With Key (Deprecated)

let removedKey = try await Amplify.Storage.remove(key: "myKey")
print("Deleted \(removedKey)")
let sink = Amplify.Publisher.create {
try await Amplify.Storage.remove(key: "myKey")
}.sink {
if case let .failure(error) = $0 {
print("Failed: \(error)")
}
}
receiveValue: { removedKey in
print("Deleted \(removedKey)")
}