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

Get a permanent URL for object #588

Closed
sidhantpanda opened this issue Apr 21, 2017 · 21 comments
Closed

Get a permanent URL for object #588

sidhantpanda opened this issue Apr 21, 2017 · 21 comments

Comments

@sidhantpanda
Copy link

Hey, there is provision for getting a preSignedUrl but we need to supply an expiry time.

Is it possible to get a permanent link to the object, so that the url can be saved in the db upon completion of put object request? How to correctly set the bucket policy for this, as the policies listed are not the same as the policies in S3?

@krishnasrinivas
Copy link
Contributor

@sidhantpanda

There can't be a permanent presigned URL.

What you can do instead is, create objects whose names are:

public/obj1
public/obj2
public/obj3
public/obj4
public/obj5

And make the prefix public/ publicly accessible using this command:
mc policy download myminio/testbucket/public/

more about mc: https://github.com/minio/mc

@sidhantpanda
Copy link
Author

@krishnasrinivas is there a way to have URLs to public objects without making an API call to Minio? I want to render pages with images and videos served directly from the Minio server.

@harshavardhana
Copy link
Member

@krishnasrinivas is there a way to have URLs to public objects without making an API call to Minio? I want to render pages with images and videos served directly from the Minio server.

To list objects one needs to make an API call you can use following CLI to get the list as well alternatively.

mc policy links play/testbucket --recursive 
https://play.minio.io:9000/testbucket/0001-dsync.patch
https://play.minio.io:9000/testbucket/filename.txt
https://play.minio.io:9000/testbucket/mc
https://play.minio.io:9000/testbucket/my-objectname
https://play.minio.io:9000/testbucket/test1
https://play.minio.io:9000/testbucket/test1.txt
https://play.minio.io:9000/testbucket/test2.txt
https://play.minio.io:9000/testbucket/1/ldap/client.go
https://play.minio.io:9000/testbucket/1/ldap/example.go
https://play.minio.io:9000/testbucket/accounts/1.original.jpg
https://play.minio.io:9000/testbucket/accounts/2.original.jpg
https://play.minio.io:9000/testbucket/accounts/c4a3ec89-3adf-40dc-822f-2d5ca8e22e32.original.jpg
https://play.minio.io:9000/testbucket/documents/1_files/issue
https://play.minio.io:9000/testbucket/documents/2_files/issue
https://play.minio.io:9000/testbucket/resumes/4.large.png
https://play.minio.io:9000/testbucket/resumes/4.original.pdf
https://play.minio.io:9000/testbucket/resumes/4.thumb.png

@krishnasrinivas
Copy link
Contributor

@krishnasrinivas is there a way to have URLs to public objects without making an API call to Minio? I want to render pages with images and videos served directly from the Minio server.

Yes, you can serve images/videos directly from Minio server to web-browser without authentication if you set the the policy on the bucket as "download"

mc policy download myminio/testbucket/

more about mc: https://github.com/minio/mc

@aprilandjan
Copy link

After set the policy of specific bucket to download in minio server, we can get the resource public url as follow:

var publicUrl = minioClient.protocol + '//' + minioClient.host + ':' + minioClient.port + '/' + minioBucket + '/' + obj.name

@TAnas0
Copy link

TAnas0 commented Nov 1, 2017

@harshavardhana
I have files successfully stored in Minio. I can list the links to different objects using the command you provided:mc policy links myminio/mybucket --recursive
I have my policies right for the different object and I can access them anonymously.

Is there a way I can get the same results using Python Client API?

In fact what interests me the most is the https://play.minio.io:9000/ since I can append to it the rest of the link. Is that address fix? Is it configurable? etc
Thanks in advance

@harshavardhana
Copy link
Member

You have to construct the url yourself. You know endpoint, bucket and you have object name.

@TAnas0
Copy link

TAnas0 commented Nov 1, 2017

@harshavardhana
While debugging, the minioClient in question has only an attribute _endpoint_url which is equal to http://localhost:9000
Using the command:

./mc policy links myminio/mediabucket --recursive
http://172.19.0.3:9000/mediabucket/pexels-photo-620332X.jpeg
http://172.19.0.3:9000/mediabucket/user159/email/pexels-photo-620332XX.jpeg
http://172.19.0.3:9000/mediabucket/pexels-photo-620332.jpeg

How can I retrieve this endpoint: http://172.19.0.3:9000?
I know it is configured in config.json but I don't know what the best approach is, since I don't know if it changes or not, and how would that affect my app once I try to deploy it.

@harshavardhana
Copy link
Member

Please come to slack.minio.io for discussion like these, we can avoid discussing here on closed issues or feel free to open a new one under minio-py

@ghost
Copy link

ghost commented Dec 29, 2017

These stuff are really useful, but not well documented. The discussion here is confusing but does help at the end. Thanks

@harshavardhana
Copy link
Member

@phuyem the documentation is not capturing FAQs ATM. We are working on finishing it for further usefulness and clarity.

@JohnDotOwl
Copy link

@harshavardhana
While debugging, the minioClient in question has only an attribute _endpoint_url which is equal to http://localhost:9000
Using the command:

./mc policy links myminio/mediabucket --recursive
http://172.19.0.3:9000/mediabucket/pexels-photo-620332X.jpeg
http://172.19.0.3:9000/mediabucket/user159/email/pexels-photo-620332XX.jpeg
http://172.19.0.3:9000/mediabucket/pexels-photo-620332.jpeg

How can I retrieve this endpoint: http://172.19.0.3:9000?
I know it is configured in config.json but I don't know what the best approach is, since I don't know if it changes or not, and how would that affect my app once I try to deploy it.

Anyway to hide the port?

@prabhuSub
Copy link

Hi,
Is there a way to get these links through a Python API call?
Suggestions would be much appreciated. I know about the presigned_get_object method for the client to fetch the link to the file, which is downloadable, but it is not a direct link to the file like an 's3://bucket-name/file.csv' would do, or even the above link examples would do.
How to fetch such links using Python API is my question/concern. Any suggestions would help! Thank you and appreciate your time reading this.

eirianop added a commit to nesi/gadr-tools that referenced this issue May 10, 2021
@Dannybrown2710
Copy link

@harshavardhana
While debugging, the minioClient in question has only an attribute _endpoint_url which is equal to http://localhost:9000
Using the command:

./mc policy links myminio/mediabucket --recursive
http://172.19.0.3:9000/mediabucket/pexels-photo-620332X.jpeg
http://172.19.0.3:9000/mediabucket/user159/email/pexels-photo-620332XX.jpeg
http://172.19.0.3:9000/mediabucket/pexels-photo-620332.jpeg

How can I retrieve this endpoint: http://172.19.0.3:9000?
I know it is configured in config.json but I don't know what the best approach is, since I don't know if it changes or not, and how would that affect my app once I try to deploy it.

Anyway to hide the port?

Use Proxy server

@anirbandas18
Copy link

anirbandas18 commented Sep 11, 2021

@krishnasrinivas is there a way to have URLs to public objects without making an API call to Minio? I want to render pages with images and videos served directly from the Minio server.

To list objects one needs to make an API call you can use following CLI to get the list as well alternatively.

mc policy links play/testbucket --recursive 
https://play.minio.io:9000/testbucket/0001-dsync.patch
https://play.minio.io:9000/testbucket/filename.txt
https://play.minio.io:9000/testbucket/mc
https://play.minio.io:9000/testbucket/my-objectname
https://play.minio.io:9000/testbucket/test1
https://play.minio.io:9000/testbucket/test1.txt
https://play.minio.io:9000/testbucket/test2.txt
https://play.minio.io:9000/testbucket/1/ldap/client.go
https://play.minio.io:9000/testbucket/1/ldap/example.go
https://play.minio.io:9000/testbucket/accounts/1.original.jpg
https://play.minio.io:9000/testbucket/accounts/2.original.jpg
https://play.minio.io:9000/testbucket/accounts/c4a3ec89-3adf-40dc-822f-2d5ca8e22e32.original.jpg
https://play.minio.io:9000/testbucket/documents/1_files/issue
https://play.minio.io:9000/testbucket/documents/2_files/issue
https://play.minio.io:9000/testbucket/resumes/4.large.png
https://play.minio.io:9000/testbucket/resumes/4.original.pdf
https://play.minio.io:9000/testbucket/resumes/4.thumb.png

What is the equivalent API call to this CLI command that will provide me the same output?

I am using minio java SDK version 8.3.0 and the API methods available in io.minio.messages.Item class doesn't seem to provide a property that would give me the absolute URL to itself (object)

Any pointers?

@prakashsvmx
Copy link
Member

prakashsvmx commented Sep 11, 2021

You can use list objects api and presigned get url.
A sample web implementation can be found in
https://github.com/prakashsvmx/minio-js-web-browser-example/blob/f0513c63c2d3b51f20467387556ad7c91cd93c78/src/ListObjects.js#L37

Also you can make the bucket public using policy so you can directly access the objcets

@anirbandas18
Copy link

You can use list objects api and presigned get url.
A sample web implementation can be found in
https://github.com/prakashsvmx/minio-js-web-browser-example/blob/f0513c63c2d3b51f20467387556ad7c91cd93c78/src/ListObjects.js#L37

Also you can make the bucket public using policy so you can directly access the objcets

This is useful

@CanRau
Copy link

CanRau commented Feb 2, 2022

Had to use mc policy set download alias/bucket/

note the set after policy

@prakashsvmx
Copy link
Member

@CanRau

some built in policies are provided for ease of use and convenience.

Please check
https://docs.min.io/docs/javascript-client-api-reference#setBucketPolicy

you could export the policy using mc and use/modify or create a new policy and apply it as per your requirements.

# Set the policy on a bucket
$ mc policy set download local/test-bucket
Access permission for `local/test-bucket` is set to `download`

# get the policy json
$ mc policy get-json local/test-bucket


# Pass this via API

@hiven
Copy link

hiven commented Dec 18, 2023

All my files are public as they are for images etc. Is there no way using the python API just to get the URL of these. Using predesigned URL on public images doesn't make sense in this case and it seems a bit of a round about way to have to construct URL from name, bucket, end point etc without just being able to call something like object_url.

@prakashsvmx
Copy link
Member

@hiven , If bucket is public the url would be like http[s]://host[:apiport]/bucket/path/object.
E.g CDN url, refrence an image in an IMG tag in html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests