Graph File Upload API - Images are getting corrupted - microsoft-graph-api

When I am trying to upload image using graph EndPoint then images are getting corrupted.
Endpoint - PUT https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}:/{file_name}:/content
Anything I am missing here?
SharePoint Message When trying to view uploaded (through above code)image. Tried without encoding as well. Even file name is not encoded then also its same behavior.
Note - This issue is with only images. Other files like PDF, CSV are working fine.

Changing form-data to binary solved my problem.

Related

Active Storage: filenames with special characters

In my application, users can change the background image of a banner. They upload the file using Simple Form and Active Storage. It's working correctly but we had a user trying to upload a file name banner-website.png (2).png. The file is uploaded and saved but doesn't appear as a background image. I guess this happens because of special characters in the filename.
What is recommended to avoid such situations? Do we need to sanitize file names?
Several things to check:
Check the console and tried to view the CSS and see if the full link
is being populated? Try checking the CSS code and copy the link to
an address bar to see if the image loads from that direction.
Check the users png file to make sure its not corrupt. PNG headers that are corrupt can cause issues displaying in a website.
Check to see if your sanitizing plugin is causing an issue with that file. I have never used that one so regarding that I cannot say.
I tried uploading a file with a same name into my Rails 6 testbench (vanilla with active storage and stimulus js) and it works fine. It could be a conflicting CSS code too.
Just my 2 cents.
I've found the solution here: Rails Active Storage - Background Image invalid property?
Adding a single quote around the URL solved it.

Google cloud storage: upload large file inside with a POST request (old createUploadUrl)

I'm migrating from PHP 5+ to PHP 7+ on standard app engine.
To upload file, I'm making a POST request to an internal endpoint with all form data (text and file to upload).
Actually what I was doing on v5 to let this work:
Get the URL with CloudStorageTools::createUploadUrl
POST everything to the url returned from the step before
In this way, all posted form (text and file to upload) was posted correctly to my internal endpoint and file can be uploaded on google storage.
Migrating to php 7+ CloudStorageTools::createUploadUrl can't be used.
Direcly upload working fine, if file is not so bigger.
For bigger file I haven't still found a solution, a lot of people have this problem but seems no one actually solved it.
There is some workaround or some tips to solve it?
I've already tested different methods got from here: https://googleapis.github.io/google-cloud-php/#/docs/cloud-storage/v1.23.2/storage/readme
No one is actually working (I got URL where upload, but at the end of upload everything crash).
Google documentation about that is not so clear, they say you can't use the older library, but actually online I can find always the same basically code that it's not good for larger file.

Microsoft Graph API, corrupted files

I am using this document to upload excel files to OneDrive https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online.
The API call in Postman is:
https://graph.microsoft.com/v1.0/me/drive/root:/FolderA/cn.xlsx:/content?
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
The issue is that the file got uploaded, but it is always being corrupted. The reason I believe is that the file is being convert to text file first, and then convert back to excel file due to the file extension (xlsx).
Does anyone know how I can get around this issues? Thank you very much.
Postman's snippet
Postman's snippet 2
Try to put 'text/plain' in content-type when you upload the bytes. This resolved my problem.

Images tags not showing in wicked_pdf gem

I have a rails app, in which i store some images in AWS, and show them in a PDF report. When there is no images to be shown, i show a placeholder, like this one here: .
The problem is: the image is not show in the PDF file. When in debug mode, the image is shown as usual, but never in my PDF! The link to the image is like this: https://dl.dropboxusercontent.com/u/4096865/missing.png
Edit 1:
I tried to include the image like this: image_tag("https://dl.dropboxusercontent.com/u/4096865/missing.png")
The solution i've found was simple, but prevented me from using dropbox for storage: it must be a http url. So, when i uploaded it to AWS S3, it worked!
So, this here works perfectly: image_tag("http://s3-sa-east-1.amazonaws.com/base-fisc-prod/missing.png")
This is an issue with images stored in a HTTPS link, the easiest way to solve this is to store the images in a HTTP link.
If you must store them in HTTPS, use this solution provided here

Sporadically images uploaded to S3 with aws-s3 & paperclip gems have a AccessDenied error when trying to view them. 99% work fine though?

I am using the aws-s3 & paperclip gems to upload images from my Rails app.
The images always get uploaded correctly, and 99% of the images can be viewed fine from my web-app.
But sometimes, an image won't load. If I paste the url into the brower, I get an error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>value_here</RequestId>
− <HostId>
value_here
</HostId>
</Error>
I don't know why this is happening, as the same code is being used to upload every image.
When I go to the AWS console I can open the image from there fine. I can't see anything different with the images that don't work. Here's a screenshot of the permissions of one of the images that doesn't work, from what I can tell they're the same as the other images:
What is causing this problem?
Edit:
Some more detail. You can upload an image 2 ways in my app, either by file upload or by providing an image URL. Both methods work fine 99% of the time.
I get the access denied error everytime I try to upload this file by providing the url:
http://www.quadrant.org.au/img/content/Jan%20Feb%202011/True%20Grit.jpg
If I save the image to my computer, and do a file upload, it works fine.

Resources