imagekit-ios
imagekit-ios copied to clipboard
Fatal error: Public Key / Authentication Endpoint is not defined while initalizing the SDK
Describe the bug Got Fatal Error: ImageKitIO/ImageKitUploader.swift:55: Fatal error: Public Key / Authentication Endpoint is not defined while initalizing the SDK
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior Upload image without error
Code ` import SwiftUI import ImageKitIO @main struct ImageKitIO_TestApp: App { init(){ initImageKitIO() }
var body: some Scene {
WindowGroup {
ContentView()
}
}
func initImageKitIO(){
_ = ImageKit.init(
publicKey: "MYPUBLIC_KEY=",
urlEndpoint: "https://ik.imagekit.io/NAME",
transformationPosition: TransformationPosition.PATH
)
}
}
struct ContentView: View {
@State var status: String? = nil
var body: some View {
Button {
upload()
} label: {
Text("Upload")
}
if let t = status {
Text(t)
.font(.largeTitle)
.foregroundColor(.red)
}
}
func upload() {
guard let image = UIImage(named: "avatar") else {
print("can't create image")
return
}
ImageKit.shared.uploader().upload(
file: image,
fileName: "sample-image.jpg",
useUniqueFilename: true,
tags: ["demo"],
folder: "/",
isPrivateFile: false,
customCoordinates: "",
responseFields: "",
signatureHeaders: ["x-test-header":"Test"],
progress: { progress in
// Handle Progress
},
completion: { result in
switch result {
case .success(let uploadAPIResponse):
// Handle Success Response
print(uploadAPIResponse)
status = "success"
case .failure(let error as UploadAPIError):
// Handle Upload Error
status = error.localizedDescription
case .failure(let error):
// Handle Other Errors
status = error.localizedDescription
}
}
)
}
}
`
Desktop (please complete the following information):
- Xcode 13.2
Smartphone (please complete the following information):
- iOS 15.2