ByteBaker opened a new issue, #3300:
URL: https://github.com/apache/arrow-rs/issues/3300

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   I use **ObjectStore** in a project that requires uploading files (mostly 
PDF) to AzureBlobStorage, and sometimes to S3. These files are later displayed 
on a web page using the ***<iframe>*** tag.
   
   Since **object_store** doesn't support including **content-type** header 
with the file to be uploaded, it becomes a problem with AzureBlobStorage, which 
defaults the ***content-type*** to **application/octet-stream**. In such case, 
***<iframe>*** downloads the file instead of displaying it. Also mentioned in 
[this StackOverflow 
question](https://stackoverflow.com/questions/50949201/iframe-downloads-the-html-source-instead-of-displaying-it).
   
   **Describe the solution you'd like**
   
   Have the ability to add a **content-type** header while uploading a file 
using **ObjectStore**.
   
   **Describe alternatives you've considered**
   
   I've written some code modifying the ObjectStore trait's method definition, 
adding an addition argument **content_type: Option<&str>**
   
   ```
   pub async fn put_request<T: Serialize + crate::Debug + ?Sized + Sync>(
           &self,
           path: &Path,
           bytes: Option<Bytes>,
           is_block_op: bool,
           query: &T,
           content_type: Option<&str>,
       ) -> Result<Response> {
           let credential = self.get_credential().await?;
           let url = self.config.path_url(path);
   
           let mut builder = self.client.request(Method::PUT, url);
   
           if !is_block_op {
               builder = builder.header(&BLOB_TYPE, "BlockBlob").query(query);
           } else {
               builder = builder.query(query);
           }
   
           if let Some(ct) = content_type {
               builder = builder.header(&CONTENT_TYPE, ct);
           }
   
           if let Some(bytes) = bytes {
               builder = builder
                   .header(CONTENT_LENGTH, HeaderValue::from(bytes.len()))
                   .body(bytes)
           } else {
               builder = builder.header(CONTENT_LENGTH, 
HeaderValue::from_static("0"));
           }
   
           let response = builder
               .with_azure_authorization(&credential, &self.config.account)
               .send_retry(&self.config.retry_config)
               .await
               .context(PutRequestSnafu {
                   path: path.as_ref(),
               })?;
   
           Ok(response)
       }
   ```
   
   **Additional context**
   
   This solution works very well for me, and I have it in my local setup. The 
problem I face is that I also use **delta-rs** crate, where I need to use 
**ObjectStore** as the backend. Therefore I cannot use my code, because it then 
says `trait not satisfied`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to