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

Fatal error: Public Key / Authentication Endpoint is not defined while initalizing the SDK #9

Closed
soyoungcheng opened this issue Mar 15, 2022 · 0 comments · Fixed by #20
Assignees

Comments

@soyoungcheng
Copy link

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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
@ahnv ahnv self-assigned this Mar 18, 2022
@ahnv ahnv closed this as completed in #20 Jun 11, 2024
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 a pull request may close this issue.

2 participants