Recently Upgraded my System to macOS 15 Sequoia Beta and Xcode 16 Beta. Everything downloaded and working fine but Predictive Code Completion Model Stuck in Downloading.
System - MacBook Air 2020, M1, 16GB RAM, 256GB(114GB available) storage.
Post
Replies
Boosts
Views
Activity
This Code is not working. Any Help will be appreciated.
func UPLOAD_VIDEO_WITH_DATA(_ video: [UploadImageInfo], param: [String: Any]) {
if !APIManager.isConnectedToNetwork() {
APIManager().networkErrorMsg()
return
}
let url = URL(string: API.CAMPAIGN.create)!
var request = URLRequest(url: url)
let boundary = "Boundary-\(NSUUID().uuidString)"
var body = Data()
body.append(boundary)
body.append("--\(boundary)\r\n")
body.append("Content-Disposition: form-data; name=\"params\"\r\n")
body.append("Content-Type: application/json\r\n\r\n")
body.append("\(param)")
body.append("\r\n")
let tempDirectoryURL = FileManager.default.temporaryDirectory
let videoURL = tempDirectoryURL.appendingPathComponent("video.mp4")
for videoInfo in video {
if videoInfo.video != nil {
if let videoData = videoInfo.data {
try? videoData.write(to: videoURL)
body.append("--\(boundary)\r\n")
body.append("Content-Disposition: form-data; name=\"video\"; filename=\"\(videoInfo.video?.absoluteString)\"\r\n")
body.append("Content-Type: video/mp4\r\n\r\n")
body.append(videoData)
body.append("\r\n")
}
}
}
body.append("--\(boundary)--\r\n")
request.httpMethod = "POST"
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
request.setValue("Bearer \(self.getMultipartHeaderWithToken())", forHTTPHeaderField: "Authorization")
request.httpBody = body
print(request)
let session = URLSession(configuration: URLSessionConfiguration.background(withIdentifier: "com.app.Deloa.backgroundUpload"))
DispatchQueue.global().async {
let task = session.uploadTask(with: request, fromFile: videoURL)
task.resume()
}
}
public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
if let error = error {
print("Error uploading data: \(error)")
} else {
print("Data uploaded successfully!")
}
}
extension Data {
mutating func append(_ string: String) {
if let data = string.data(using: .utf8) {
append(data)
}
}
}
Here is the data i am passing for video
` override func selectedVideo(choosenVideo: URL, thumbnailImage: UIImage) {
var selectedVideo = UploadImageInfo()
selectedVideo.name = "video"
selectedVideo.video = choosenVideo
selectedVideo.data = try? Data(contentsOf: choosenVideo)
selectedVideo.url = choosenVideo.absoluteString
self.media.append(selectedVideo)
var selectedThumbnail = UploadImageInfo()
selectedThumbnail.name = "thumbnail"
selectedThumbnail.image = thumbnailImage
selectedThumbnail.data = compressImage(image: thumbnailImage)
self.media.append(selectedThumbnail)
}`
Upload Image struct
struct UploadImageInfo {
var id: Int
var name: String
var image: UIImage?
var video : URL?
var thumbnail: UIImage?
var data: Data?
var url: String?
init() {
name = ""
image = nil
video = nil
id = 0
thumbnail = nil
data = nil
url = nil
}
}
I have an application, in which I want to send data of user activity to our server when the user killed/closed the application. If it is unsuccessful in sending data to the server in the background then I will send all data when the user relaunches the app again. Is there a method to do this?
A Failed to launch process. Failed to attach to stub for playground execution: error: debugserver is x86_64 binary running in translation, attached failed..
Did anyone experience this? I want to run playground using Rosetta?
How to take multiple inputs separated by space in swift??
Showing this message -
Failed to launch process. Failed to attach to stub for playground execution: error: attach failed ((os/kern) invalid argument)