Search Results

Search found 2 results on 1 pages for 'klactose'.

Page 1/1 | 1 

  • Need help figuring out scala compiler errors.

    - by klactose
    Hello all, I have been working on a project in scala, but I am getting some error messages that I don't quite understand. The classes that I am working with are relatively simple. For example: abstract class Shape case class Point(x: Int, y: Int) extends Shape case class Polygon(points: Point*) extends Shape Now suppose that I create a Polygon: val poly = new Polygon(new Point(2,5), new Point(7,0), new Point(3,1)) Then if I attempt to determine the location and size of the smallest possible rectangle that could contain the polygon, I get various errors that I don't quite understand. Below are snippets of different attempts and the corresponding error messages that they produce. val upperLeftX = poly.points.reduceLeft(Math.min(_.x, _.x)) Gives the error: "missing parameter type for expanded function ((x$1) = x$1.x)" val upperLeftX = poly.points.reduceLeft((a: Point, b: Point) => (Math.min(a.x, b.x))) Gives this error: "type mismatch; found : (Point, Point) = Int required: (Any, Point) = Any" I am very confused about both of these error messages. If anyone could explain more clearly what I am doing incorrectly, I would really appreciate it. Yes, I see that the second error says that I need type "Any" but I don't understand exactly how to implement a change that would work as I need it. Obviously simply changing "a: Point" to "a: Any" is not a viable solution, so what am I missing?

    Read the article

  • Getting 404 when attempting to POST file to Google Cloud Storage from service account

    - by klactose
    I'm wondering if anyone can tell me the proper syntax & formatting for a service account to send a POST Object to bucket request? I'm attempting it programmatically using the HttpComponents library. I manage to get a token from my GoogleCredential, but every time I construct the POST request, I get: HTTP/1.1 403 Forbidden <?xml version='1.0' encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access denied.</Message><Detailsbucket-name</Details></Error The Google documentation that describes the request methods, mentions posting using html forms, but I'm hoping that wasn't suggesting the ONLY way to get the job done. I know that HttpComponents has a way to explicitly create form data by using UrlEncodedFormEntity, but it doesn't support multipart data. Which is why I went with using the MultipartEntity class. My code is below: MultipartEntity entity = new MultipartEntity( HttpMultipartMode.BROWSER_COMPATIBLE ); String token = credential.getAccessToken(); entity.addPart("Authorization", new StringBody("OAuth " + token)); String date = formatDate(new Date()); entity.addPart("Date", new StringBody(date)); entity.addPart("Content-Encoding", new StringBody("UTF-8")); entity.addPart("Content-Type", new StringBody("multipart/form-data")); entity.addPart("bucket", new StringBody(bucket)); entity.addPart("key", new StringBody("fileName")); entity.addPart("success_action_redirect", new StringBody("/storage")); File uploadFile = new File("pathToFile"); FileBody fileBody = new FileBody(uploadFile, "text/xml"); entity.addPart("file", fileBody); httppost.setEntity(entity); System.out.println("Posting URI = "+httppost.toString()); HttpResponse response = client.execute(httppost); HttpEntity resp_entity = response.getEntity(); As I mentioned, I am able to get an actual token, so I'm pretty sure the problem is in how I've formed the request as opposed to not being properly authenticated. Keep in mind: This is being performed by a service account. Which means that it does have Read/Write access Thanks for reading, and I appreciate any help!

    Read the article

1