I have the following folder structure in my bucket:
Structure: Bucket-Name/YEAR/Folder/Objects
Example Path: mybucket/2018/myEXEs/file.exe
Issue: When I try to download an object (file.exe) from example path above by clicking on the EXE, the filename that appears in the download dialog box looks like this:
"2018%2FmyEXEs%2Ffile.exe"
You have to strip the URL encoded path every time and this is an inconvenience if you do not want to make the URL public.
Observation:
It appears the storage browser adds bucket path to the filename and that gets encoded to replace '/'.
This does not happen when you download the object using public URL.
Question:
Is there a way to strip the URL encoded path from filename?
There is a feature request in the public tracker for this. As mentioned in the same link, there is a workaround by setting the filename in the Content-Disposition metadata of the files. To do it, go to Cloud Storage, edit metadata of a file and, in Content-Disposition field, add:
attachment; filename="filename"
The the only inconvenient with this workaround is that you have to set filenames in all the download files's metadatas.
Related
Click to open image
In POSTMAN documentation I have a post request with uploading image(form-data) and I need to remove the path of files in my computer
I have the path like this:
/C:/Users/user/Downloads/user.avatar.205.200 (1).jpg
And I need to remove or change this:
/C:/Users/user/Downloads
Our team is building a web app that allows users to download video files. We currently host our files on AWS S3, but since our site doesn't reside on AWS, we can't use <a href="blah"> to prompt download. If we use that html element, users simply get redirected to a video player - which is fine, but Safari on mobile doesn't allow for users to download the video file via the video player.
We found that manually setting the file's content disposition to attachment on S3 works, but we have not found a way to automate that. We tried adding a content-disposition: attachment key-value pairing in our payload, which works, but adds a "User defined" meta data in the form of x-amz-meta-content-disposition, which doesn't work as the file could not be downloaded as an attachment. It seems only "System defined" works.
Has anyone ever encountered this issue before and found a workaround?
see screenshot for what I'm referencing
You can set the content disposition when the file is created.
This is done by uploading the file via a presigned url.
See https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html for details on the presigned urls.
Alternatively you can use a presigned url to return to get the file from S3 and override the content disposition header on the GET request.
When I visit a public URL to my uploaded file, the filename includes the prefix, resulting in a super long filename.
Is there a way to download a file from the browser without including the prefix?
Maybe a setting or metadata to the uploaded file, or something?
My backend runs on NodeJS, if that's relevant.
In your webserver, you can override the default file name by writing a specific header
request.setHeader('Content-Disposition', 'filename="fileName.txt"');
I would like to share my Postman-Collection including a multipart/form-data request with a very specific file so everything is contained within the Postman-Collection itself.
I tried several approaches like setting the value to text and adding the picture in base64 format and setting the content-type to image/jpeg;base64 or prefixing the value with base64,<base64encodedString> and several combinations that I could think of, but to no avail.
The only documentation/hint I found was setting a postman variable that contains a dynamic definition of where the file is located - this does not solve my problem here though.
How do I embed a file within a Postman multipart/form-data request?
In postman multiform you can upload a file by hovering over the field and selecting type as file.
Example :
change type to file from text. Also enable the column content-type ( it will be generated automatically you don't have to chagne anything)
Other examples:
https://apidocs.imgur.com/
The above has a demo endpoint shows how to upload a image.
My question came out when I experienced two different behaviors in object URL from json files stored in a s3 bucket.
Consider a json file: mydata.json
If I upload this file using s3 dashboard from AWS website, I am able to see data in browser: //s3-us-west-2.amazonaws.com/bucket/folder/mydata.json. I am also able to read this data from a different application if I create a specific configuration in s3 bucket.
For the other hand, if I use boto3 library for python and upload the same file in the same bucket (making file public in the process), when I click object URL it downloads the file, but it doesn't open data in browser.
This is the code I used:
# upload json file
bucket.upload_file(path, jsonkey)
object_acl = s3.ObjectAcl('bucket_name', jsonkey)
bucket_response = object_acl.put(ACL='public-read')
I explored file properties such as metadata. When I upload file via dashboard, the metadata assigned is Content-Type: application/json, and via boto3 is Content-Type: binary/octet-stream. I don't really know if metadata affects the object URL behavior.
In this context, how can I properly configure files in json format to be downloaded or to be read? I mean, what is the main configuration that affects object URL behavior?
I couldn't find a significant difference between both methods (dashboard and boto3) in properties or permissions, besides Content-Type in metadata. However, when I tried to change Content-Type, behavior was the same.
Any other information I can provide to clarify this question, be free to ask. Thanks in advance.
The documentation for the S3 bucket resource's upload_file() method is not ideal as it simply refers you to the equivalent S3Transfer docs for how extra arguments can be used.
Try the following:
bucket.upload_file(path, jsonkey, ExtraArgs={'ContentType': "application/json"})