that was a very useful read. i have a number of uses for this thank you for sharing
Another user can access to that url??
Thank
How I can delete the photo I upload to the server?
How I can delete the photo I upload to the server?
Hi Luis,
You can use SparkFiles deleteUploadedFile call to remove user uploaded files. You can read more about this here.
Thanks,
Liam
Do you need to authenticate a user or anything else before this code? mine does not seem to work.
Thanks
Hello, I am abale to the url but uploading is not working. I have swift code here,
func uploadImage(urlString: String!, paramName: String, fileName: String, image: UIImage) { let url = URL(string: urlString) // generate boundary string using a unique per-app string let boundary = UUID().uuidString let session = URLSession.shared // Set the URLRequest to POST and to the specified URL var urlRequest = URLRequest(url: url!) urlRequest.httpMethod = "POST" // Set Content-Type Header to multipart/form-data, this is equivalent to submitting form data with file upload in a web browser // And the boundary is also set here urlRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") var data = Data() // Add the image data to the raw http request data data.append("\r\n--\(boundary)\r\n".data(using: .utf8)!) data.append("Content-Disposition: form-data; name=\"\(paramName)\"; filename=\"\(fileName)\"\r\n".data(using: .utf8)!) data.append("Content-Type: image/png\r\n\r\n".data(using: .utf8)!) data.append(image.pngData()!) data.append("\r\n--\(boundary)--\r\n".data(using: .utf8)!) // Send a POST request to the URL, with the data we created earlier session.uploadTask(with: urlRequest, from: data, completionHandler: { responseData, response, error in self.hideActivity() if error == nil { let jsonData = try? JSONSerialization.jsonObject(with: responseData!, options: .allowFragments) if let json = jsonData as? [String: Any] { print(json) } } }).resume() }
Customer Support
Here's a sample script that takes a screenshot, uploads it to GameSparks and then allows you to re-download it.
Shane