Hi team, I’m integrating Algolia instant search into my app and have run into an issue with images.
I’m providing Algolia with the download URL for an avatar image to show in the results list item. It’s been working fine for the last 24 hours or so, but today the oldest images all stopped appearing. When opening them in their own browser tab I see the following message:
application AAdy0pa… policy error: the signature has expired
Is there a way to get an image URL that won’t expire?
Hi, thank you for your report!
First of all, we don’t recommend to use persistent download URL. Here are some solutions:
You could call createField mutation and set expiration time property in fieldTypeAttributes as you need. If you want to set expire time equals 2 days, you have to set “60 * 60 * 24 * 2”
Another way to download files is to use shareUrl property. This property links to 8base server, then the server will ask to login to 8base. This solution is used when you need to pass a link to email or whatever. It’s guaranteed to protect your file data. If you want to make this file public, just setup permission to allow all access to this file.
If the user already has token and don’t have to login to 8base, you could add to shareUrl “download” query parameter.
For example “shareUrl”?download=true. Otherwise, if the file has public access, the user will not have to have any token.
In this case, the server will parse you token and proxy to temporary download url.
I need a persistent download URL for image files for an article system where I cannot use GraphQL (need to be a direct url to the image file location).
However if you go to that url you’ll just see the 8base loader?
The downloadUrl I presume will only be valid for 24 hours, and I need this url to be static (not change) and still be valid 5 years from now.
The only thing I need files for on this account is to show images in articles, so privacy is not a concern. I want everything to be public and accessible without a login / token.
How can I get a persistent url without querying 8base for it?
I agree, I’m having the same problem. I need to load images in public content from a static url.
I’m not sure what @eugene.antonevich means by “If you want to make this file public, just setup permission to allow all access to this file.”. I tried setting the public boolean on the image to true (by running a mutation on the database) and then using the shareUrl, but going to the shareUrl just shows the spinning 8base loader like @MarkLyck said. I also looked at roles and permission settings in the admin dashboard, but I don’t see how to set permissions for general public access, only for specific roles/API keys.
How do we get a static url to the images that we’ve uploaded to the 8base database?
First of all, there is the issue with sharedUrl and we will research it.
Anyway, there are several opportunities to download file.
Did you try to add “download=true” to the end of sharedUrl? For example, the sharedUrl for some file is “https://app.8base.com/some_path”, then add “?download=true” to the end. The result url is https://app.8base.com/some_path?download=true. Then try to fetch this url. The server will redirect you to direct download link for the file if permissions are valid. In case of public file the user could download file through sharedUrl without any token. As the result you have static download url for public file.
Is it what you need ?
It seems to be either time related or you have the edit the file to make it work.
Right after uploading a file with public=true, the shareUrl doesn’t work.
However an old file I uploaded with public=false, then edited to be public=true. That file’s shareUrl works.
Just uploaded another file with public=true and here’s it’s shareUrl:
If it’s a bug, I’m just gonna hold our until it’s sorted out. Otherwise, I have all the information to create the “real” link. But as a user, this is definitely confusing and I would expect shareUrl to be the same returned when Creatin it as it would be from fetching the row afterwards.
I could create it manually. like https://api.8base.com/file/download/${workspaceId}_Master/${fileId}?download=true but I find it a bit odd.
Please let me know if this is a bug and I should hold out, or if. this is intentional and I’ll use the above string-concatenation to create the real shareUrl.
For example. To test it you could try to create file with client web picker. In the network tab you could find the request to the server with the file create mutation. The result of the request contain sharedUrl and it looks fine too.
It seems like you try to fetch the “original” sharedUrl after perform create file mutation.
@MarkLyck there is another way you can extend the expiration time on a image link indefinitely by updating a meta value called expiration on the file relationship.
For example, let’s say I have a Users table with an Image field called favoritePhoto. I can manually set the expiration time on that specific relationship.
First, you’d need to get the ID of the Table Field:
query {
system {
table(name: "Users") {
fields {
id
displayName
}
}
}
}
Once you have the ID of the favoritePhoto field, then you can set the following fieldAttribute with a mutation.
So now, let’s say I update the expiration to one-billion seconds (1,000,000,000), whenever a downloadUrl is generated for my favoritePhoto it would expire after 31 years.