parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 735 forks source link

Picasso reaching parse localhost ip instead of the server ip #1082

Closed pythonistastic closed 3 years ago

pythonistastic commented 3 years ago

Hello guys,

I have been trying to get data from parse and then show it in my android application, the text fields are showing with no issue but when I use Picasso to get the image url from parse it goes to the localhost ip instead of the server ip.

I have used the following code to connect to parse server:

Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) .applicationId("myappID") .clientKey(Key) .server("http://public_ip/parse/") .build() );

I am using this code for calling the image with Picasso: Picasso.get().load(thingsObject.getParseFile("image").getUrl()).resize(400,400).into(holder.productImage);

According to Picasso logs this is what is happening: "Request{http://127.0.0.1:1337/parse/files/myappID/e0525f94.jpg"

Help me please

Jawnnypoo commented 3 years ago

Is your server actually http and not https? This will cause many issues.

pythonistastic commented 3 years ago

Is your server actually http and not https? This will cause many issues.

Yes for the mean time I am still developing my android app so its still http not https .. do you mean security issues or is there another issues related to fetching the images from the database?

Jawnnypoo commented 3 years ago

Unless you modify the OkHttp instance and change things in your manifest, all network traffic should be failing. As for the images, its hard to know exactly what is going on. Do you upload these files from the Android SDK? Are they hosted on MongoDB? Can you view them in Parse Dashboard and see if the URL is incorrect there as well?

pythonistastic commented 3 years ago

Unless you modify the OkHttp instance and change things in your manifest, all network traffic should be failing. As for the images, its hard to know exactly what is going on. Do you upload these files from the Android SDK? Are they hosted on MongoDB? Can you view them in Parse Dashboard and see if the URL is incorrect there as well?

Yes I have modified the manifest added the internet access and network access .. which was a success for the app to fetch the text data from parse dashboard .. as for the images i have added them manually on the dashboard uploading it directly to the row.. and opening them with the public ip of server I was able to see the images in the browser .. but am not sure if its MongoDB I am using AWS and having the parse instance hosted there

Jawnnypoo commented 3 years ago

I am not sure why this is happening, seems like potentially an issue with the Parse backend. Worst case scenario, you could just getUrl().replace("127.0.0.1:1337", "your-domain-here.com")

pythonistastic commented 3 years ago

I am not sure why this is happening, seems like potentially an issue with the Parse backend. Worst case scenario, you could just getUrl().replace("127.0.0.1:1337", "your-domain-here.com")

That worked fantastic and the images are being fetched successfully gonna stick with this solution for now.. I have read in the documentation that .getParseFile function will not perform a network request .. but anyway thanks alot man really appreciate it 🙌

Jawnnypoo commented 3 years ago

No problem! Happy to help 👍