-
I migrated to upload api v3.
After that, all my files CIDs are bafkr* while legacy api generated bafkr* for text files and bafyb* for binary files.
That is the reason for a change?
What are side effects?
Can I maintain old behavior?
My code:
url = URI.parse("https://uploads.pinata.cloud/v3/files") io = StringIO.new(io) if io.is_a?(String) # Form data form_data = [ ["network", network], ["name", key], ["group_id", @group_id], ["keyvalues", JSON.generate(key:)], ['file', io, { filename: "file" }] ] req = Net::HTTP::Post.new(url) req["Authorization"] = authorization_header req.set_form(form_data, "multipart/form-data") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true res = Errors.retryable(interval: 3) do http.request(req) end unless res.is_a?(Net::HTTPSuccess) raise ActiveStorage::IntegrityError, "Upload failed: #{res.code} #{res.body}" end JSON.parse(res.body).dig("data", "cid")
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment